.net

The locale en-EN is an invalid culture identifier

允我心安 提交于 2021-02-20 18:59:07
问题 I recently shifted from a computer which had Windows 10 with VS 2017 to a computer which had Windows 8.1 with VS 2017. I was working with a piece of code which had a line like this. Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(locale); Here, locale value is en-EN . I got hit with a surprise when this threw a CultureNotFoundException exception with a message. en-EN is an invalid culture identifier. Surprising to me because, the same code with locale as en-EN works in

The locale en-EN is an invalid culture identifier

耗尽温柔 提交于 2021-02-20 18:58:38
问题 I recently shifted from a computer which had Windows 10 with VS 2017 to a computer which had Windows 8.1 with VS 2017. I was working with a piece of code which had a line like this. Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(locale); Here, locale value is en-EN . I got hit with a surprise when this threw a CultureNotFoundException exception with a message. en-EN is an invalid culture identifier. Surprising to me because, the same code with locale as en-EN works in

Parsing TimeSpan from string including format

五迷三道 提交于 2021-02-20 15:01:47
问题 I'm sure this must be simple, but I can't figure out how to word it correctly in Google... I have a config which has a field: TimeToPoll="1d" Now I want to do something like : TimeSpan.Parse(TimeToPoll); Returning a timespan of one day. In C# EDIT: I'm looking for a method which allows parse of "1d" as well as "1s" or "1y" etc. Is this possible? Meaning: "1d" parses to {1.00:00:00} "1h" parses to {0.01:00:00} "1m" parses to {0.00:01:00} "1s" parses to {0.00:00:01} 回答1: The d is not needed and

Parsing TimeSpan from string including format

℡╲_俬逩灬. 提交于 2021-02-20 14:56:03
问题 I'm sure this must be simple, but I can't figure out how to word it correctly in Google... I have a config which has a field: TimeToPoll="1d" Now I want to do something like : TimeSpan.Parse(TimeToPoll); Returning a timespan of one day. In C# EDIT: I'm looking for a method which allows parse of "1d" as well as "1s" or "1y" etc. Is this possible? Meaning: "1d" parses to {1.00:00:00} "1h" parses to {0.01:00:00} "1m" parses to {0.00:01:00} "1s" parses to {0.00:00:01} 回答1: The d is not needed and

Static variable order [duplicate]

僤鯓⒐⒋嵵緔 提交于 2021-02-20 13:32:23
问题 This question already has answers here : Static field initialization order (C#) - can someone explain this snippet? (6 answers) Closed 7 years ago . I have aproblem with the order of static variable declaration in C# When i run this code: static class Program { private static int v1 = 15; private static int v2 = v1; static void Main(string[] args) { Console.WriteLine("v2 = "+v2); } } The output is: v2=15 But when i change the static variable declaration order like this: static class Program {

RX - rethrow an error in containing method

泄露秘密 提交于 2021-02-20 10:31:43
问题 I need to translate an error in an RX stream ( IObservable ) into an exception in the method that contains the subscription to the stream (because of this issue https://github.com/aspnet/SignalR/pull/1331 , Whereby errors arent serialised to clients.) Once this issue is fixed I will revert to handling error properly e.g. I have the following method public IObservable<StreamItem> LiveStream() { _mySvc.Start(); return _mySvc.ThingChanged(); } So I have tried to subscribe to the stream and

Types don't match for creating a CLR Stored Procedure

丶灬走出姿态 提交于 2021-02-20 07:02:58
问题 I have a method in an assembly that looks like this: namespace MyNameSpace { public class MyClass { [Microsoft.SqlServer.Server.SqlProcedure] public static void MyMethod(SqlChars myMessage) { // Stuff here } } } I compile that to a dll and load it into my SQL Server like this: drop assembly MyAssembly create assembly MyAssemblyfrom 'C:\Scripts\MyAssembly.dll' That all works fine. But now I try to run this: CREATE PROCEDURE MySproc @message nvarchar(max) AS EXTERNAL NAME MyAssembly.

one of the parameters of a binary operator must be the containing type c#

怎甘沉沦 提交于 2021-02-20 06:25:50
问题 public static int[,] operator *(int[,] arr1, int[,] arr2) { int sum; int[,] res = new int[arr1.GetLength(0), arr2.GetLength(1)]; for (int i = 0; i < arr1.GetLength(0); i++) { for (int j = 0; j < arr2.GetLength(1); j++) { sum = 0; for (int k = 0; k < arr1.GetLength(1); k++) { sum = sum + (arr1[i, k] * arr2[k, j]); } res[i, j] = sum; //Console.Write("{0} ", res[i, j]); } //Console.WriteLine(); } return res; } Here i am trying to overload * operator to multiply two matrices.. but the compiler

one of the parameters of a binary operator must be the containing type c#

≡放荡痞女 提交于 2021-02-20 06:19:52
问题 public static int[,] operator *(int[,] arr1, int[,] arr2) { int sum; int[,] res = new int[arr1.GetLength(0), arr2.GetLength(1)]; for (int i = 0; i < arr1.GetLength(0); i++) { for (int j = 0; j < arr2.GetLength(1); j++) { sum = 0; for (int k = 0; k < arr1.GetLength(1); k++) { sum = sum + (arr1[i, k] * arr2[k, j]); } res[i, j] = sum; //Console.Write("{0} ", res[i, j]); } //Console.WriteLine(); } return res; } Here i am trying to overload * operator to multiply two matrices.. but the compiler

one of the parameters of a binary operator must be the containing type c#

亡梦爱人 提交于 2021-02-20 06:18:37
问题 public static int[,] operator *(int[,] arr1, int[,] arr2) { int sum; int[,] res = new int[arr1.GetLength(0), arr2.GetLength(1)]; for (int i = 0; i < arr1.GetLength(0); i++) { for (int j = 0; j < arr2.GetLength(1); j++) { sum = 0; for (int k = 0; k < arr1.GetLength(1); k++) { sum = sum + (arr1[i, k] * arr2[k, j]); } res[i, j] = sum; //Console.Write("{0} ", res[i, j]); } //Console.WriteLine(); } return res; } Here i am trying to overload * operator to multiply two matrices.. but the compiler