Skip to main content
Filter by
Sorted by
Tagged with
700 votes
28 answers
1.3m views

I read the C++ version of this question but didn't really understand it. Can someone please explain clearly if it can be done in C#, and how?
Ash's user avatar
  • 9,221
248 votes
31 answers
241k views

I was curious about how other people use the this keyword. I tend to use it in constructors, but I may also use it throughout the class in other methods. Some examples: In a constructor: public ...
99 votes
20 answers
444k views

I want to pass values between two Forms (c#). How can I do it? I have two forms: Form1 and Form2. Form1 contains one button. When I click on that button, Form2 should open and Form1 should be in ...
Nagu's user avatar
  • 5,144
17 votes
2 answers
24k views

I find the best way to save game data in Unity3D Game engine. At first, I serialize objects using BinaryFormatter. But I heard this way has some issues and is not suitable for save. So, What is the ...
Sizzling's user avatar
  • 315
1472 votes
296 answers
762k views

This came to my mind after I learned the following from this question: where T : struct We, C# developers, all know the basics of C#. I mean declarations, conditionals, loops, operators, etc. Some ...
259 votes
19 answers
188k views

I have a list of people's ID and their first name, and a list of people's ID and their surname. Some people don't have a first name and some don't have a surname; I'd like to do a full outer join on ...
ninjaPixel's user avatar
  • 6,385
75 votes
12 answers
56k views

I have a form that spawns a BackgroundWorker, that should update form's own textbox (on main thread), hence Invoke((Action) (...)); call. If in HandleClosingEvent I just do bgWorker.CancelAsync() then ...
THX-1138's user avatar
  • 21.8k
222 votes
13 answers
421k views

I'm writing a simple import application and need to read a CSV file, show result in a DataGrid and show corrupted lines of the CSV file in another grid. For example, show the lines that are shorter ...
ilkin's user avatar
  • 2,942
730 votes
20 answers
685k views

When building console applications that take parameters, you can use the arguments passed to Main(string[] args). In the past I've simply indexed/looped that array and done a few regular expressions ...
Paul Stovell's user avatar
  • 32.8k
107 votes
11 answers
479k views

How can I put a sleep function between the TextUI.text = ...., to wait 3 seconds between each phrase? public Text GuessUI; public Text TextUI; [...truncated...] TextUI.text = "Welcome to Number ...
DiogoSaraiva's user avatar
  • 1,715
1178 votes
11 answers
496k views

What is the difference between a DateTime and a DateTimeOffset and when should one be used? Currently, we have a standard way of dealing with .NET DateTimes in a TimeZone-aware way: Whenever we ...
David Reis's user avatar
  • 13.8k
75 votes
6 answers
68k views

In both queries 1 and 2, the text from the textbox is inserted into the database. What's the significance of the parameterized query here? Passing txtTagNumber as a query parameter SqlCommand cmd = ...
sqlchild's user avatar
  • 9,126
19 votes
3 answers
32k views

Why does the following program print what it prints? class Program { static void Main(string[] args) { float f1 = 0.09f*100f; float f2 = 0.09f*99.999999f; Console....
Prankster's user avatar
  • 4,097
741 votes
36 answers
450k views

I'm trying to use the Html.DropDownList extension method but can't figure out how to use it with an enumeration. Let's say I have an enumeration like this: public enum ItemTypes { Movie = 1, ...
181 votes
7 answers
252k views

I'm trying to install a service using InstallUtil.exe but invoked through Process.Start. Here's the code: ProcessStartInfo startInfo = new ProcessStartInfo (m_strInstallUtil, strExePath); System....
Scott Marlowe's user avatar
599 votes
15 answers
590k views

How can I validate a username and password against Active Directory? I simply want to check if a username and password are correct.
user avatar
576 votes
13 answers
393k views

What is the best way to copy the contents of one stream to another? Is there a standard utility method for this?
Anton's user avatar
  • 6,990
264 votes
7 answers
174k views

I've seen them both being used in numerous pieces of C# code, and I'd like to know when to use i++ and when to use ++i? (i being a number variable like int, float, double, etc).
Dlaor's user avatar
  • 3,040
538 votes
18 answers
192k views

The MSDN documentation says that public class SomeObject { public void SomeOperation() { lock(this) { //Access instance variables } } } is "a problem if the instance can ...
188 votes
8 answers
147k views

I'm trying to filter on the initial query. I have nested include leafs off a model. I'm trying to filter based on a property on one of the includes. For example: using (var context = new ...
Jason N. Gaylord's user avatar
316 votes
21 answers
330k views

In our application, we receive text files (.txt, .csv, etc.) from diverse sources. When reading, these files sometimes contain garbage, because the files where created in a different/unknown codepage. ...
GvS's user avatar
  • 52.5k
939 votes
62 answers
1.4m views

I am trying to run some unit tests in a C# Windows Forms application (Visual Studio 2005), and I get the following error: System.IO.FileLoadException: Could not load file or assembly 'Utility, ...
leora's user avatar
  • 198k
393 votes
9 answers
350k views

Is there a way in C# where I can use reflection to set an object property? Ex: MyObject obj = new MyObject(); obj.Name = "Value"; I want to set obj.Name with reflection. Something like: Reflection....
Melursus's user avatar
  • 10.7k
632 votes
28 answers
593k views

I am looking for a better pattern for working with a list of elements which each need processed and then depending on the outcome are removed from the list. You can't use .Remove(element) inside a ...
InvertedAcceleration's user avatar
430 votes
12 answers
250k views

System.Net.Http.HttpClient and System.Net.Http.HttpClientHandler in .NET Framework 4.5 implement IDisposable (via System.Net.Http.HttpMessageInvoker). The using statement documentation says: As a ...
Fernando Correia's user avatar