[Solved] Clone Enity framework POCO

I found a nice turn around . If you try MemberwiseClone() to get a copy of the object and then add the object to the context and SaveChanges() you will get an error because the MemberwiseClone() does clone the Dynamic Proxy too . So my turn around is Create a new Context just for the … Read more

[Solved] Why is “‐” == “-” false? [closed]

These are different symbols. Add these lines to your fiddle to see it: Console.WriteLine((int)’‐’); Console.WriteLine((int)’-‘); You can write your own comparison function and treat all different variants of hyphen as the same symbol or you can replace all such symbols in your strings with the one hyphen variant before the comparison. 3 solved Why is … Read more

[Solved] LastIndexOf bug? [closed]

As per the docs: public int LastIndexOf (char value, int startIndex, int count) “The search proceeds from startIndex toward the beginning of this instance.” The first comma before index 223 occurs at index 221. 0 solved LastIndexOf bug? [closed]

[Solved] regex to exact match 11 digit phone number from string and remove hyphen(-) from match in c#

You can use below Regex to remove all hyphens and all other non numeric characters from phone number string pattern = @”\b([\-]?\d[\-]?){11}\b”; Regex rgx = new Regex(pattern); var sentence = “This is phone number 0341-2239548 and 021-34223311″; var matches = rgx.Matches(sentence); foreach (Match match in matches) { string replacedValue = Regex.Replace(match.Value, @”[^0-9]”, “”); sentence = … Read more

[Solved] How to insert a single row data in a excel in c#?

Indeed, this question already exists in stack overflow. By the way you can try this simple solution. public void loggeneration(DateTime datetime, string projectname, int totallines, int sum, int max) { // this is the variable to your xls file string path = @”c:\temp\log.xls”; // This text is added only once to the file. if (!File.Exists(path)) … Read more

[Solved] Unary value type [closed]

I think what you are asking is not possible. But you can use constants. const string s = “I’m a constant and I’ll not change”; But the word variable itself speaks itself. It varies But for your sake how about this: struct Uoolean { } A empty struct? No matter what object you create from … Read more

[Solved] Need to get time part

I must say thanks to user853710 for a quick pattern. This will help you to collect the date from the given sting, and DateTime.TryParseExact plays the key role in the extraction process: string pattern = @”\d{4}-\d{2}-\d{2} \d{1,2}:\d{1,2}:\d{1,2}”; string p = “v 0 fl 0x4; value 8 feat 0; sn AC0809099; mn -; tim 2015-10-11 20:50:36 … Read more

[Solved] Converting php to c#, curl to .net [closed]

You do not specify anything, not even if it is a GET or POST, but this is an example from Postman using restsharp var client = new RestClient(“https://google.com”); var request = new RestRequest(Method.GET); request.AddHeader(“postman-token”, “49bab31b-6be2-5862-e3ca-351cb8b35d86”); request.AddHeader(“cache-control”, “no-cache”); IRestResponse response = client.Execute(request); solved Converting php to c#, curl to .net [closed]