草庐IT

list_of_ids

全部标签

c# - 如何在设计时避免 XAML 代码中出现 "object reference not set to an instance of an object"异常?

我自己设计的wpf用户控件有问题。问题是,当我在我的程序中实现用户控件时,在设计时XAML代码中出现objectreferencenotsettoaninstanceofanobject异常。设计师向我展示了以下信息:atMicrosoft.Expression.Platform.InstanceBuilders.InstanceBuilderOperations.InstantiateType(Typetype,BooleansupportInternal)atMicrosoft.Expression.Platform.InstanceBuilders.ClrObjectInstan

c# - 是否可以将 GroupCollection 转换为 List 或 IEnumerable?

是否可以将GroupCollection转换为List或IEnumerable?我指的是正则表达式中的GroupCollection。 最佳答案 当然GroupCollectioncol=...;IEnumerableenumerable=col.Cast();Listlist=col.Cast().ToList(); 关于c#-是否可以将GroupCollection转换为List或IEnumerable?,我们在StackOverflow上找到一个类似的问题:

c# - 如何将 List<T> 转换为 DataSet?

给定一个对象列表,我需要将其转换为一个数据集,其中列表中的每个项目都由一行表示,每个属性是该行中的一列。然后这个数据集将被传递给Aspose.Cells功能,以便将Excel文档创建为报告。假设我有以下内容:publicclassRecord{publicintID{get;set;}publicboolStatus{get;set;}publicstringMessage{get;set;}}给定一个List记录,我如何将其转换为DataSet,如下所示:IDStatusMessage1true"message"2false"message2"3true"message3"...目前

c# - 将 List<T> 转换为 List<object>

我对泛型类有疑问。我有这样的东西:publicabstractclassIGroup:IEnumerablewhereT:class{protectedListgroupMembers;protectedListgroupIGameActionList;publicIGroup(){groupMembers=newList();groupIGameActionList=newList();//groupIGameActionList.Add(newDieGameAction(groupMembers));}}第二类:classDieGameAction:IGameAction{List

c# - 将 XmlNodeList 转换为 List<string>

是否可以转换XmlNodeList到List无需声明新的List?我正在为此寻找一个简单的实现:System.Xml.XmlNodeListmembersIdList=xmlDoc.SelectNodes("//SqlCheckBoxList/value");ListmemberNames=newList();foreach(System.Xml.XmlNodeiteminmembersIdList){memberNames.Add(library.GetMemberName(int.Parse(item.InnerText)));} 最佳答案

c# - 使用 Web API 和 JSON.NET 序列化对象时防止 $id/$ref

我似乎无法阻止WebAPI/JSON.NET在序列化对象时使用Newtonsoft.Json.PreserveReferencesHandling.Objects。换句话说,尽管使用了以下设置,但$id/$ref始终在序列化对象中使用:publicclassMvcApplication:System.Web.HttpApplication{protectedvoidApplication_Start(){WebApiConfig.Register(GlobalConfiguration.Configuration);}}publicstaticclassWebApiConfig{pub

c# - 如何从 List<T> 中跳过(m).take(n)?

给定:Listlist=newList{1,2,3,4,5,6,7,8,9,10};如何实现以下代码?varlist2=list.skip(2).take(5); 最佳答案 只要您在using语句中包含System.Linq(并修复您的方法名称.Skip(2)和),您的示例代码就可以正常工作。取(5)).您的代码无法开箱即用的原因是.Skip和.Take是找到的扩展方法(与List类中定义的方法相反)在“System.Linq”命名空间中。 关于c#-如何从List中跳过(m).take

c# - 如何使用 EF 迁移将 int ID 列更改为 Guid?

我正在使用EF代码优先方法并想将Id字段更改为guid但似乎无法通过以下错误。这是我的第一次迁移:publicpartialclassCreateDownloadToken:DbMigration{publicoverridevoidUp(){CreateTable("dbo.DownloadTokens",c=>new{Id=c.Int(nullable:false,identity:true),FileId=c.Int(),UserId=c.String(nullable:false,maxLength:128),ValidUntil=c.DateTime(nullable:fal

c# - 如何根据 T 的属性对 List<T> 进行排序?

我的代码是这样的:CollectionoptionInfoCollection=....ListoptionInfoList=newList();optionInfoList=optionInfoCollection.ToList();if(_isAlphabeticalSoting)SortoptionInfoList我试过optionInfoList.Sort()但它不起作用。 最佳答案 使用sort方法和lambda表达式,真的很容易。myList.Sort((a,b)=>String.Compare(a.Name,b.Nam

c# - 错误 : Cannot implicitly convert type 'void' to 'System.Collections.Generic.List'

我正在尝试使用该控件从.ascx设置我的.ascx控件的属性。所以在我的一个包含此控件的.aspx中,我有以下代码试图设置我的嵌入式.ascx的ItemsList属性:Itemitem=GetItem(itemID);myUsercontrol.ItemList=newList().Add(item);我尝试设置的.ascx中的属性如下所示:publicListItemsList{get{returnthis.itemsList;}set{this.itemsList=value;}}错误:无法将类型“void”隐式转换为“System.Collections.Generic.List