草庐IT

string_view

全部标签

c# - 如何在不在 wpf 中引入新引用的情况下从 View 模型 (.cs) 调用窗口 (.xaml.cs) 中的方法

我正在寻找一种在我的主窗口中调用方法的简单方法,但我想从我的View模型中调用它。基本上,我正在寻找某种“this.parent”之王,将其放入View模型中以引用主窗口。或者,如果您想了解我想要这样做的原因并告诉我另一种解决问题的方法:我正在使用一个不断获取信息的应用程序。在View模型中,信息被处理。我想在每次有满足某种条件的信息进来时发出通知。最初,我在View模型中有一个字典,用于存储有关该信息的信息,我在MainWindow中访问该字典,以便我可以使窗口闪烁并发送其他通知。但是当我在MainWindow中访问它时,我遇到了viewmodel的字典不断变化的问题。如果这个问题听

c# - ICollection<string> 到 string[]

我有一个ICollection类型的对象.转换为string[]的最佳方式是什么?.如何在.NET2中完成此操作?如何在更高版本的C#中更清晰地完成此操作,或许在C#3中使用LINQ? 最佳答案 您可以使用以下代码片段将其转换为普通数组:string[]array=newstring[collection.Count];collection.CopyTo(array,0);这应该可以完成工作:) 关于c#-ICollection到string[],我们在StackOverflow上找到一

C# Linq - 无法将 IEnumerable<string> 隐式转换为 List<string>

我有一个这样定义的列表:publicListAttachmentURLS;我正在像这样向列表中添加项目:instruction.AttachmentURLS=curItem.Attributes["ows_Attachments"].Value.Split(';').ToList().Where(Attachment=>!String.IsNullOrEmpty(Attachment));但我收到此错误:无法将IEnumerable隐式转换为列表我做错了什么? 最佳答案 Where方法返回IEnumerable.尝试添加.ToLis

c# - 在 C# 中将数据 View 复制到数据表的最简单方法?

我需要将数据View复制到数据表中。似乎这样做的唯一方法是逐项遍历数据View并复制到数据表。一定有更好的方法。 最佳答案 dt=DataView.ToTable()或dt=DataView.Table.Copy(),或dt=DataView.Table.Clone(); 关于c#-在C#中将数据View复制到数据表的最简单方法?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7

c# - 如何将 XML 转换为 List<string> 或 String[]?

如何将以下XML转换为List或String[]:12 最佳答案 听起来您更多的是在解析之后而不是完整的XML序列化/反序列化。如果您可以使用LINQtoXML,这将非常简单:usingSystem;usingSystem.Linq;usingSystem.Xml.Linq;publicclassTest{staticvoidMain(){stringxml="12";XDocumentdoc=XDocument.Parse(xml);varlist=doc.Root.Elements("id").Select(element=>e

c# - 如何将 string[] 转换为 ArrayList?

我有一个字符串数组。如何将其转换为System.Collections.ArrayList? 最佳答案 string[]myStringArray=newstring[2];myStringArray[0]="G";myStringArray[1]="L";ArrayListmyArrayList=newArrayList();myArrayList.AddRange(myStringArray); 关于c#-如何将string[]转换为ArrayList?,我们在StackOverfl

c# - 如何在一行 C# 3.0 中将 object[] 转换为 List<string>?

好吧,我放弃了,你如何在一行中做到这一点?publicobjectConvert(object[]values,TypetargetType,objectparameter,System.Globalization.CultureInfoculture){//Listfields=values.ToList();//Listfields=valuesasList;//Listfields=(List)values;Listfields=newList();foreach(objectvalueinvalues){fields.Add(value.ToString());}//proce

c# - 这段代码怎么可能: "ArgumentOutOfRangeException: startIndex cannot be larger than length of string"?

我的C#代码中有以下方法://////Removesthefirst(leftmost)occurenceofafroma.//////Thestringtoremovethefrom.Cannotbenull.///Thesubstringtolookforandremovefromthe.Cannotbenull.//////Therestofthe,afterthefirst(leftmost)occurenceoftheinit(ifany)hasbeenremoved.////////////Ifthedoesnotoccurwithinthe,theisreturnedin

c# - String.GetHashCode() 返回不同的值

为什么GetHashCode()为同一个字符串返回不同的值?我无法描述如何复制它,但请相信这不是一个恶作剧,并且以下两行来self的watch窗口在两个不同的时间:"DDD.Events.Application.ApplicationReferenceCreated".GetHashCode()-1386151123int"DDD.Events.Application.ApplicationReferenceCreated".GetHashCode()1858139950int怎么会这样?我不知道这是否有帮助,但我在VS2010中运行.NET4.0,并且正在调试NServiceBus应

c# - 是否通过 AutoMapper 将域模型映射到 View 模型

我想使用View模型来显示领域模型。而我想自定义一个属性来显示,我应该怎么做呢?使用AutoMapper进行显示是否是一种好的做法?下面是代码示例:publicclassBookController:BaseController{privateIBookServicebookService;publicBookController(IBookServicebookService){this.bookService=bookService;}publicActionResultDetails(intid){varbook=bookService.GetBookById(id);retur