If I have these strings: "abc" = false "123" = true "ab2" = false Is there a command, like IsNumeric or something else, that can identify if a string is a valid number? int n; bool isNumeric = int.TryParse("123", out n); Update As of C# 7: var isNumeric = int.TryParse("123", out int n); The var s can be replaced by their respective types! This will retu
如果我有这些字符串: "abc" = false "123" = true "ab2" = false 是否有像IsNumeric或其他的命令可以识别字符串是否是有效的数字? int n; bool isNumeric = int.TryParse("123", out n); 更新从C#7开始: var isNumeric = int.TryParse("123", out int n); var s可以用各自的类型替换! 如果input是全部数字,这将返回true。 不知道它是否比TryParse更好,但它可以工作。 Regex
I'm trying to understand when and when not to use the restrict keyword in C and in what situations it provides a tangible benefit. After reading, "Demystifying The Restrict Keyword", ( which provides some rules of thumb on usage ), I get the impression that when a function is passed pointers, it has to account for the possibility that the data pointed to might overlap (alias) with
我试图了解何时以及何时不在C中使用restrict关键字,以及在何种情况下它提供了实实在在的好处。 阅读后,“解密限制关键字”(提供了一些关于使用的规则),我得到的印象是,当一个函数被传递指针时,它必须考虑指向的数据可能重叠(别名)与任何其他参数传递给函数。 给定一个函数: foo(int *a, int *b, int *c, int n) { for (int i = 0; i<n; ++i) { b[i] = b[i] + c[i]; a[i] = a[i] + b[i] * c[i]
How do you do "inline functions" in C#? I don't think I understand the concept. Are they like anonymous methods? Like lambda functions? Note : The answers almost entirely deal with the ability to inline functions, ie "a manual or compiler optimization that replaces a function call site with the body of the callee." If you are interested in anonymous (aka lambda) func
你如何做C#中的“内联函数”? 我不认为我理解这个概念。 他们喜欢匿名方法吗? 像lambda函数一样? 注意 :答案几乎完全处理内联函数的能力,即“手动或编译器优化,用被调用者的主体替换函数调用站点”。 如果您对匿名(aka lambda)函数感兴趣,请参阅@ jalf的答案或每个人都在说的“Lambda”是什么? 最后在.NET 4.5中,CLR允许使用MethodImplOptions.AggressiveInlining值提示/建议1方法内联。 它也可以在Mono的行李箱
I'm working on a new version of my Mandelbrot screensaver and I'm running out of floating point accuracy - simple double values don't have enough significant figures for my needs. More significant figures = greater levels of zooming into the fractal Back when I wrote a version of this screensaver in Delphi 7, I used the extended floating point type, 80 bits in size. In .NET, I c
我正在研究Mandelbrot屏幕保护程序的一个新版本,而且我的浮点数精度不够 - 简单的double值没有足够的重要数字来满足我的需求。 更有意义的数字=放大到分形的更高级别 当我在Delphi 7中编写这个屏幕保护程序的版本时,我使用了80位扩展浮点类型。 在.NET中,我可以切换到十进制,但性能受到影响很糟糕,使分形的生成速度减慢了20倍左右。 有没有扩展的.NET等价物? 或者,或者,是否有任何数字类型的精度高于仍然使用FP
I install Microsoft Outlook 14.0 Object Library, Then And I programmed using C#. My app references Outlook 2010 Primary Interop Assemblies.(Microsoft Outlook 14.0 Object Library) Can I use any Outlook version with this PIA? (Outlook 2000,Outlook 2003,Outlook 2007,Outlook 2010) In that case, do I need to modify my program to reference the old PIAs? "Sort of". One cannot use an
我安装了Microsoft Outlook 14.0 Object Library,然后使用C#编程。 我的应用程序引用了Outlook 2010主互操作程序集(Microsoft Outlook 14.0 Object Library) 我可以在PIA上使用任何Outlook版本吗? (Outlook 2000,Outlook 2003,Outlook 2007,Outlook 2010) 在那种情况下,我是否需要修改我的程序以引用旧的PIA? “有点”。 任何PIA呼叫都不能使用任何版本的Outlook。 但是,可以使用特定底层Outlook COM支持
I am using the PayPal sandbox in ASP.Net C# 4.0. I added the following web references: https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl When I run this code: PayPalAPIHelper.PayPalSandboxWS.SetExpressCheckoutReq req = new PayPalAPIHelper.PayPalSandboxWS.SetExpressCheckoutReq() { SetExpressCheckoutRequest = new PayPalAPIH
我在ASP.Net C#4.0中使用PayPal沙箱。 我添加了以下Web引用: https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl 当我运行这段代码时: PayPalAPIHelper.PayPalSandboxWS.SetExpressCheckoutReq req = new PayPalAPIHelper.PayPalSandboxWS.SetExpressCheckoutReq() { SetExpressCheckoutRequest = new PayPalAPIHelper.PayPalSandboxWS.SetExpr
I want to compile a simple "hello world" on mac console. I have made dmcs symbolic on /usr/local/bin/. using System; class Hello { static void Main(){ Console.WriteLine("Hello,World"); } } But after typing dmcs Hello.cs I get Hello.exe .exe file seems a Windows file. So, How to compile single c# file on mac console using mono? JamesSugrue is right in yo
我想在Mac控制台上编译一个简单的“hello world”。 我在/ usr / local / bin /上创建了dmcs符号。 using System; class Hello { static void Main(){ Console.WriteLine("Hello,World"); } } 但打字后 dmcs Hello.cs 我得到Hello.exe .exe文件似乎是一个Windows文件。 那么,如何使用mono在mac控制台上编译单个c#文件? JamesSugrue在您的评论中是正确的,您需要使用描述的命令行使用mono框架
I'm trying to add log4net onto our MonoMac solution. Built fine but no log file is generated. I've got a log4net config that works fine in a Windows application. We're referencing the CLI build log4net (for mono v2). Windows is happy with it and we get logs as expected. Now in Mac, I've tried a separate log4net.config file (preferable) - it's built correctly and appears
我正在尝试将log4net添加到我们的MonoMac解决方案中。 生成良好,但没有生成日志文件。 我有一个可以在Windows应用程序中正常工作的log4net配置。 我们引用CLI构建log4net(对于单声道v2)。 Windows对此感到满意,我们按预期获得了日志。 现在在Mac中,我尝试了一个单独的log4net.config文件(最好) - 它的构建正确并出现在Mac上的输出区域,其名称在app.config中提到。 仍然没有输出。 我试过把所有的配置放在app.
I would like to develop Mono application for Win/Linux/Mac in C# on Windows. Is there any really good (Visual Studio comparable) IDE for that? The best would be if I could manage Visual C# Express to compile solutions using the Mono compiler. I've found a #develop IDE, which looks very cool and has many features that Express edition of the Visual Studio hasn't (like plugins for Tortoi
我想在Windows上用C#开发Win / Linux / Mac的Mono应用程序。 有没有什么非常好的(与Visual Studio相媲美的)IDE? 如果我可以管理Visual C# Express来使用Mono编译器编译解决方案,那么最好的办法是。 我找到了一个#develop IDE,它看起来非常酷,并且具有许多Express版本的Visual Studio没有的特性(比如TortoiseSVN,NUnit等的插件)。 Hovewer的3. *版本降低了对Mono的支持,所以你不再能够使用Mono编译器编译解决方案
Simple xaml: <WrapPanel Orientation="Vertical"> <Ellipse Width="100" Height="100" Fill="Red" /> <Ellipse Width="100" Height="100" Fill="Yellow" /> <Ellipse Width="100" Height="100" Fill="Green" /> </WrapPanel> Resizing window: How to show vertical and horizontal scrollbars when content doesn't fit? Note: this should work for any content. I tri
简单的xaml: <WrapPanel Orientation="Vertical"> <Ellipse Width="100" Height="100" Fill="Red" /> <Ellipse Width="100" Height="100" Fill="Yellow" /> <Ellipse Width="100" Height="100" Fill="Green" /> </WrapPanel> 调整窗口大小: 内容不适合时如何显示垂直和水平滚动条? 注意:这应该适用于任何内容。 我试图把它放到ScrollViewer : <ScrollViewer Horizont