[Solved] C# Accessing field syntax

[ad_1] You can use reflection to access a field by its name : FieldInfo ageField = typeof(Person).GetField(“age”); int age = (int) field.GetValue(person); [ad_2] solved C# Accessing field syntax

[Solved] How do I get latitude and longtitude for desktop application? [closed]

[ad_1] A standard GPS device (internal or external) sends data on a serial port. Receiving any data from Serial Port is very easy. Please check this link. //define serial port SerialPort serialPort1 = new SerialPort(); //configuring the serial port serialPort1.PortName=”COM1″; serialPort1.BaudRate=9600; serialPort1.DataBits=8; serialPort1.Parity=Parity.None; serialPort1.StopBits= StopBits.One; //read data from serial port string data = serialPort1.ReadExisting(); GPS … Read more

[Solved] Adding values from textbox to label [closed]

[ad_1] I believe what you are trying to do is to add a value to PizzaPrice, then display it on txtPizzaPrice.Text with the £ sign appended to the front. PizzaPrice should be a property rather than a field. public double PizzaPrice { get; set; } Notice that I += the value to pizza price, then … Read more

[Solved] Check if null before set to null?

[ad_1] No, there is not much use. Probably checking the variable being null or not is just as expensive as setting it to null one time too many. If it was a property, with additional logic behind it, it could make sense to test it before, but that should actually be the responsibility of the … Read more

[Solved] Find and replace dynamic values via for loop

[ad_1] I think this is what you want, List<string> keys = new List<string>() { “name”, “age”, “param3” }; string url = “http://www.test.com/test.aspx?testinfo=&|&;”; Regex reg = new Regex(“&”); int count = url.Count(p => p == ‘&’); for (int i = 0; i < count; i++) { if (i >= keys.Count) break; url = reg.Replace(url, keys[i], 1); … Read more

[Solved] How to create byte array and fill it with random data [duplicate]

[ad_1] Try the Random.NextBytes method https://docs.microsoft.com/en-us/dotnet/api/system.random.nextbytes?view=netframework-4.7.2 private byte[] GetByteArray(int sizeInKb) { Random rnd = new Random(); byte[] b = new byte[sizeInKb * 1024]; // convert kb to byte rnd.NextBytes(b); return b; } If you need cryptographically safe random bytes, use System.Security.Cryptography.RNGCryptoServiceProvider instead. 7 [ad_2] solved How to create byte array and fill it with random … Read more

[Solved] How to create folder on server pc in C# [duplicate]

[ad_1] As explained in MSDN: Directory.CreateDirectory: You can create a directory on a remote computer, on a share that you have write access to. UNC paths are supported; Keyword here being “UNC paths”, which take the following form: \\server-name\share-name\[subdirectory-names\] So: Directory.CreateDirectory(@”\\server-name\share-name\NewFolder1″); 0 [ad_2] solved How to create folder on server pc in C# [duplicate]

[Solved] Must declare the scalar variable “@lblCmpUserName”

[ad_1] I got the solution, I made a mistake in my INSERT query. It should be like this. string query=”INSERT INTO Company_Info2 VALUES (@UserName,@Cmp_Name,@Comm_Country, @Commercial_RegNo,@Cmp_DocPath, @Cmp_EstablishDate,@Cmp_Address,@IsAddress)”; [ad_2] solved Must declare the scalar variable “@lblCmpUserName”

[Solved] Japenese character in a filename changes to garbage if I download file from IE 11

[ad_1] I found the solution, here it is, I used UrlEncode on the filename which helped me solve my problem. Response.AddHeader(“Content-Disposition”, String.Format(“attachment; filename={0}”, HttpUtility.UrlEncode(docFileDTO.FileName))); [ad_2] solved Japenese character in a filename changes to garbage if I download file from IE 11