[Solved] why instance variable returns null in c#? [closed]

So, where you call GetSingleLocationInfo, you are calling an async method. GetSingleLocationInfo calwill therefore run as far as the await statement then return stright to the caller, before the it httpClient.GetStringAsync(hereNetUrl); has returned. To fix this, you need to await on your call GetSingleLocationInfo before trying to access the variable. 1 solved why instance variable … Read more

[Solved] sort in Ascending Order [closed]

Did little example to understand object parsing into int type parameter. List<object> _obj = new List<object>() { “10”, “20”, “30”, “d”, “a”, “t” }; int sum = 0; for (int i = 0; i < _obj.Count; i++) { int temp; //parsing object into int type, when we cant parse object will be 0 int.TryParse(_obj[i].ToString(), out … Read more

[Solved] Show String Data in Message Box C#

Try this: MessageBox.Show(String.Format(“{0}, {1}, {2}:”, city, zip, state)); This go replace {0} with the variable city, {1}with the variable zip and {3} with state. String.Format converts the value of objects to strings based on the formats specified and inserts them into another string. If you are new, read getting started with the String.Format method New … Read more

[Solved] Optimize parsing more and more…. in C# [closed]

There’s nothing more you can optimize there. And I doubt that THIS is the slowest place in your program. However your null-values are a bit odd. -999 for numbers? DateTime.Now for a DateTime? Are you sure that won’t cause problems in other code? Those are pretty normal values which means that other code won’t be … Read more

[Solved] How to call a service from console Application in c#

HttpWebRequest req = null; HttpWebResponse resp = null; string baseaddress = “http://deveqtradedb.lazard.com/API.aspx?action=export&entity=global”; req = (HttpWebRequest)WebRequest.Create(baseaddress); req.Method = “POST”; req.ContentType = “text/xml; encoding = UTF-8”; resp = req.GetResponse() as HttpWebResponse; Check Here https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse(v=vs.110).aspx solved How to call a service from console Application in c#

[Solved] How to Remove number from Extension with string?

You can use regex as shown or a simple LINQ query, i’d also recommend System.IO.Path: string originalPath = “Url1234.pdf”; string dir = Path.GetDirectoryName(originalPath); // in this case “” string extension = Path.GetExtension(originalPath); // .pdf string fn = Path.GetFileNameWithoutExtension(originalPath); // Url1234 string newFn = String.Concat(fn.Where(c => !Char.IsDigit(c))); // Url string newPath = Path.Combine(dir, newFn + extension); … Read more

[Solved] Datatable to dictionary [closed]

Based on the additional information, the problem is that you are not passing the right arguments to ToDictionary. It takes two lambdas, not a lambda and a List<>. Here’s the first step to fixed code: dt.AsEnumerable().ToDictionary( dtRow => dtRow.Field<Int64>(“CodeVal_1”), dtRow => new List<string> { dtRow.Field<string>(“CodeVal_2”), dtRow.Field<string>(“CountryCode”) } ); EDIT: fixed using wrong version of ToDictionary. … Read more

[Solved] auto click in C# in difrent position of screen [closed]

in WPF you can use this line of code to set mouse position [System.Runtime.InteropServices.DllImport(“user32.dll”)] static extern bool SetCursorPos(int x, int y); this line to firing the event [System.Runtime.InteropServices.DllImport(“user32.dll”)] static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo); private const int MOUSEEVENTF_LEFTDOWN = 0x02; private const int MOUSEEVENTF_LEFTUP = 0x04; and this … Read more