草庐IT

group_name_num

全部标签

c# - 从 Nullable 类型反射获取 PropertyType.Name

我想使用反射获取属性类型。这是我的代码varproperties=type.GetProperties();foreach(varpropertyInfoinproperties){model.ModelProperties.Add(newKeyValuePair(propertyInfo.PropertyType.Name,propertyInfo.Name));}这段代码propertyInfo.PropertyType.Name没问题,但是如果我的属性类型是Nullable我得到这个Nullable'1字符串,如果写FullName如果得到这个stirngSystem.Nulla

c# - IEnumerable Group 按用户指定的动态键列表

我有一个类publicclassEmpolyee{publicstringDesignation{get;set;}publicstringDiscipline{get;set;}publicintScale{get;set;}publicDateTimeDOB{get;set;}publicintSales{get;set;}}并以可枚举的方式记录所有员工ListEmployees;和一个字符串键列表,例如varKeys=newList(){"Designation","Scale","DOB"};假设列表“键”的元素是用户指定的,用户可以不指定或指定多个键元素。现在我想使用列表“K

c# - 如何在 Linq to SQL 中使用 distinct 和 group by

我正在尝试将以下sql转换为Linq2SQL:selectgroupId,count(distinct(userId))fromprocessroundissueinstancegroupbygroupId这是我的代码:varq=fromiinProcessRoundIssueInstancegroupibyi.GroupIDintogselectnew{Key=g.Key,Count=g.Select(x=>x.UserID).Distinct().Count()};当我运行代码时,我不断收到无效的GroupID。有任何想法吗?似乎distinct把事情搞砸了..这里是生成的sql:

c# - 有没有办法在 Web.config 文件的 smtp 元素中包含电子邮件地址 "display name"?

这个问题在这里已经有了答案:关闭9年前。PossibleDuplicate:StoringSmtpfromemailfriendlydisplaynameinWeb.Config我正在处理EmailSender,我正在从我的Web.config文件中获取电子邮件地址。如果可能的话,我还想从同一部分获取该电子邮件的“显示名称”,但我没有看到一个明显的方法来做到这一点。在我的Web.config文件中,我包含了一个默认的“发件人电子邮件地址”,如下所示:在我的EmailSender中,我有这样的东西:varsmtpSection=...;varmessage=newMailMessage(

c# - VB.NET linq group by 匿名类型不能按预期工作

我正在研究LINQPad附带的一些linq示例。在“C#3.0inaNutshell”文件夹中的Chater9-Grouping下,有一个名为“GroupingbyMultipleKeys”的示例查询。它包含以下查询:fromninnew[]{"Tom","Dick","Harry","Mary","Jay"}.AsQueryable()groupnbynew{FirstLetter=n[0],Length=n.Length}我将字符串“Jon”添加到数组的末尾以获得实际分组,并得出以下结果:这正是我所期待的。然后,在LINQPad中,我转到同一查询的VB.NET版本:'Manuall

c# - 如何使用 AutomationProperties.Name?

问题任何人都可以解释(最好使用代码示例)AutomationProperties.Name属性如何以编程方式和声明方式与XAML一起使用吗?解释我了解到,例如,VisualStudio2010中的编码UI生成器将窗口的名称作为SearchProperty。由于我的窗口名称发生变化,我希望有一个常量SearchProperty,我的编码UI测试可以依赖它。在下面的代码示例中,我不希望窗口标题被硬编码为“管道1的属性”,因为它发生了变化。代码示例[GeneratedCode("CodedUITestBuilder","10.0.30319.1")]publicclassUIListView

c# - Visual Studio 变得疯狂 : 'The directory name is invalid' error when trying to compile

出于一些非常奇怪的原因,我的VisualStudio2008在尝试编译C#项目时尝试将可执行文件的输出写入与可执行文件同名的目录,至少看起来这就是错误所在消息暗示。在我的任何项目上运行编译后,CSC.EXE报告以下编译器错误:Couldnotwritetooutputfile'D:\Projects\Examples\StringBuilderVsString\obj\Release\StringBuilderVsString.exe'--'Thedirectorynameisinvalid.'当我查看obj\Release或obj\Debug时,所有中间资源(如StringBuild

c# - "Both use the XML type name X, use XML attributes to specify a unique XML name and/or namespace for the type"怎么解决?

我有以下枚举定义...namespaceItemTable{publicenumDisplayMode{Tiles,Default}}namespaceEffectiveItemPermissionTable{publicenumDisplayMode{Tree,FullPaths}}...然后我有以下类(class)...publicclassTablewhereTDisplayMode:struct{//publicpublicTDisplayModeDisplayMode{get{returnmDisplayMode;}set{mDisplayMode=value;}}//pri

c# - 路由 : How to hide action name in url?

在MVC默认路由中routes.MapRoute("Default",//Routename"{controller}/{action}/{id}",//URLwithparametersnew{controller="Home",action="Index",id=UrlParameter.Optional}//Parameterdefaults);每当访问索引操作时,当访问“索引”操作时,url不会显示操作名称。我想在另一个Controller上获得该行为,该Controller正在检索单个项目的数据。我希望将默认操作命名为“get”,对于此操作,我希望url不显示操作名称,只显示

c# - new FileInfo(path).Name 与 Path.GetFileName(path)

哪个更好用,为什么?我的意思是这两个命令在哪些方面不同以及如何不同?性能、可读性……newFileInfo(path).Name或Path.GetFileName(path) 最佳答案 因为您不必为使用Path.GetFilename()创建新对象,所以性能会更好。这是两者的比较:代码:Path.GetFileName("G:\\u.png")IL:IL_0000:ldstr"G:\u.png"IL_0005:callSystem.IO.Path.GetFileName代码:newFileInfo("G:\\u.png").Name