Skip to main content
Filter by
Sorted by
Tagged with
1866 votes
26 answers
2.5m views

I have some code and when it executes, it throws a NullReferenceException, saying: Object reference not set to an instance of an object. What does this mean, and what can I do to fix this error?
848 votes
15 answers
253k views

I have the following function: //Function to get random number public static int RandomNumber(int min, int max) { Random random = new Random(); return random.Next(min, max); } How I call it: ...
Ivan Prodanov's user avatar
1315 votes
10 answers
375k views

What's the best way to call a generic method when the type parameter isn't known at compile time, but instead is obtained dynamically at runtime? Consider the following sample code - inside the ...
Bevan's user avatar
  • 44.4k
294 votes
11 answers
83k views

I met an interesting issue about C#. I have code like below. List<Func<int>> actions = new List<Func<int>>(); int variable = 0; while (variable < 5) { actions.Add(() =&...
Morgan Cheng's user avatar
  • 76.4k
1670 votes
53 answers
1.3m views

How can you convert a byte array to a hexadecimal string and vice versa?
1148 votes
32 answers
725k views

What is the best way to randomize the order of a generic list in C#? I've got a finite set of 75 numbers in a list I would like to assign a random order to, in order to draw them for a lottery type ...
mirezus's user avatar
  • 14.3k
148 votes
11 answers
299k views

I have a list of items send from a PHP file to unity using WWW. The WWW.text looks like: [ { "playerId": "1", "playerLoc": "Powai" }, { "playerId": "2", "...
dil33pm's user avatar
  • 1,653
811 votes
43 answers
357k views

I'm using the Excel interop in C# (ApplicationClass) and have placed the following code in my finally clause: while (System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet) != 0) { } ...
HAdes's user avatar
  • 17.1k
1600 votes
33 answers
765k views

In C#, what makes a field different from a property, and when should a field be used instead of a property?
121 votes
7 answers
69k views

I've created a simple Winforms application in C#. When I run the application on a machine with high DPI settings (e.g. 150%), the application gets scaled up. So far so good! But instead of rendering ...
Boris's user avatar
  • 9,041
115 votes
4 answers
161k views

How to detect UI object on Canvas on Touch in android? For example, I have a canvas that have 5 objects such as Image, RawImage, Buttons, InputField and so on. When I touch on Button UI object Then ...
Dennis Liu's user avatar
  • 2,368
2191 votes
49 answers
1.4m views

How can I create an Excel spreadsheet with C# without requiring Excel to be installed on the machine that's running the code?
74 votes
4 answers
187k views

I have to program an application management system for my OJT company. The front end will be done in C# and the back end in SQL. Now I have never done a project of this scope before; in school we had ...
LeonidasFett's user avatar
  • 3,152
293 votes
9 answers
226k views

Can Application.DoEvents() be used in C#? Is this function a way to allow the GUI to catch up with the rest of the app, in much the same way that VB6's DoEvents does?
Craig Johnston's user avatar
84 votes
4 answers
58k views

How do I pass a whole set model object through formdata and convert it to model type in the controller? Below is what I've tried! JavaScript part: model = { EventFromDate: fromDate, ...
Guruprasad J Rao's user avatar
66 votes
15 answers
556k views

I'm looking for a library/method to parse an html file with more html specific features than generic xml parsing libraries.
Luke's user avatar
  • 19k
1215 votes
24 answers
1.2m views

I am trying implement the Data transformation using Reflection1 example in my code. The GetSourceValue function has a switch comparing various types, but I want to remove these types and properties ...
pedrofernandes's user avatar
1424 votes
26 answers
1.3m views

From my understanding one of the main things that async and await do is to make code easy to write and read - but is using them equal to spawning background threads to perform long duration logic? I'...
Dan Dinu's user avatar
  • 33.5k
399 votes
8 answers
1.7m views

Consider: namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(...
Midhat's user avatar
  • 4,317
1500 votes
17 answers
2.6m views

How can I make an HTTP POST request and send data in the body?
Hooch's user avatar
  • 29.8k
154 votes
21 answers
77k views

Anyone have a good resource or provide a sample of a natural order sort in C# for an FileInfo array? I am implementing the IComparer interface in my sorts.
Michael Kniskern's user avatar
1812 votes
15 answers
726k views

From time to time I see an enum like the following: [Flags] public enum Options { None = 0, Option1 = 1, Option2 = 2, Option3 = 4, Option4 = 8 } I don't understand what ...
Brian Leahy's user avatar
  • 35.8k
675 votes
25 answers
1.1m views

How to perform left outer join in C# LINQ to objects without using join-on-equals-into clauses? Is there any way to do that with where clause? Correct problem: For inner join is easy and I have a ...
Toy's user avatar
  • 6,803
713 votes
10 answers
714k views

I want a true deep copy. In Java, this was easy, but how do you do it in C#?
user18931's user avatar
  • 11k
48 votes
3 answers
7k views

I have been using NewtonSoft JSON Convert library to parse and convert JSON string to C# objects. But now I have came across a really awkward JSON string and I am unable to convert it into C# object ...
TaLha Khan's user avatar
  • 2,443

1
2 3 4 5
3566