Do NOT use for questions about .NET Core - use [.net-core] instead. The .NET framework is a software framework designed mainly for the Microsoft Windows operating system. It includes an implementation of the Base Class Library, Common Language Runtime (commonly referred to as CLR), Common Type System (commonly referred to as CTS) and Dynamic Language Runtime. It supports many programming languages, including C#, VB.NET, F# and C++/CLI.
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?
I have some code and when it executes, it throws a IndexOutOfRangeException, saying,
Index was outside the bounds of the array.
What does this mean, and what can I do about it?
Depending on ...
asked Jan 6 '14 at 0:19
Adriano Repetti
59.8k1717 gold badges127127 silver badges188188 bronze badges
Which is the simplest way to update a Label from another Thread?
I have a Form running on thread1, and from that I'm starting another thread (thread2).
While thread2 is processing some files I would ...
asked Mar 19 '09 at 9:37
CruelIO
16.8k1616 gold badges3636 silver badges5353 bronze badges
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 ...
asked Oct 24 '08 at 5:17
Bevan
40.8k1010 gold badges7777 silver badges128128 bronze badges
In .NET, the GetHashCode method is used in a lot of places throughout the .NET base class libraries. Implementing it properly is especially important to find items quickly in a collection or when ...
asked Nov 4 '08 at 20:53
bitbonk
45.5k3232 gold badges173173 silver badges269269 bronze badges
I want to do something like:
MyObject myObj = GetMyObj(); // Create and fill a new object
MyObject newObj = myObj.Clone();
And then make changes to the new object that are not reflected in the ...
asked Sep 17 '08 at 0:06
NakedBrunch
45.8k1313 gold badges6969 silver badges9797 bronze badges
Instead of relying on my host to send an email, I was thinking of sending the email messages using my Gmail account. The emails are personalized emails to the bands I play on my show.
Is it possible ...
asked Aug 28 '08 at 13:28
Mike Wills
19.8k2626 gold badges8787 silver badges143143 bronze badges
Is there a way to deserialize JSON content into a C# 4 dynamic type? It would be nice to skip creating a bunch of classes in order to use the DataContractJsonSerializer.
asked Jun 29 '10 at 16:04
jswanson
14.8k66 gold badges1818 silver badges1515 bronze badges
How can I create an Excel spreadsheet with C# without requiring Excel to be installed on the machine that's running the code?
Once my program is installed on a client machine, how do I force my program to run as an administrator on Windows 7?
asked May 12 '10 at 11:09
Gold
54.4k9595 gold badges206206 silver badges310310 bronze badges
I'm looking for a library/method to parse an html file with more html specific features than generic xml parsing libraries.
asked Sep 11 '08 at 9:16
Luke
17.7k2424 gold badges8181 silver badges108108 bronze badges
I'm writing a program in C# that needs to repeatedly access 1 image file. Most of the time it works, but if my computer's running fast, it will try to access the file before it's been saved back to ...
asked May 18 '09 at 6:37
Dawsy
9,35944 gold badges1818 silver badges1313 bronze badges
How can I encrypt and decrypt a string in C#?
asked Oct 14 '08 at 17:07
NotDan
30k3535 gold badges110110 silver badges154154 bronze badges
What is the difference between decimal, float and double in .NET?
When would someone use one of these?
I know from reading the Microsoft documentation that the "primary" use of the IDisposable interface is to clean up unmanaged resources.
To me, "unmanaged" means things like database connections, ...
asked Feb 11 '09 at 18:12
cwick
24.3k1212 gold badges3535 silver badges4040 bronze badges
Canonical
How can I make an HTTP request and send some data using the POST method?
I can do a GET request, but I have no idea of how to make a POST request.
asked Oct 25 '10 at 14:05
Hooch
25.1k2828 gold badges8989 silver badges153153 bronze badges
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'...
asked Jan 22 '13 at 9:29
Dan Dinu
27.7k2121 gold badges6666 silver badges100100 bronze badges
I want a true deep copy. In Java, this was easy, but how do you do it in C#?
asked Sep 24 '08 at 19:39
user18931
10.1k99 gold badges2626 silver badges2121 bronze badges
What profilers have you used when working with .net programs, and which would you particularly recommend?
Consider the below code:
public class Class1
{
public static int c;
~Class1()
{
c++;
}
}
public class Class2
{
public static void Main()
{
{
var c1=...
Example (note the case):
string s = "Hello world!";
String s = "Hello world!";
What are the guidelines for the use of each? And what are the differences?
Microsoft should have implemented something snappy for INotifyPropertyChanged, like in the automatic properties, just specify {get; set; notify;}
I think it makes a lot of sense to do it. Or are there ...
Is there any class, library or some piece of code which will help me to upload files with HTTPWebrequest?
Edit 2:
I do not want to upload to a WebDAV folder or something like that. I want to ...
asked Feb 19 '09 at 18:03
dr. evil
25.9k2828 gold badges124124 silver badges198198 bronze badges
Some guy asked me this question couple of months ago and I couldn't explain it in detail. What is the difference between a reference type and a value type in C#?
I know that value types are int, bool,...
asked Feb 20 '11 at 13:21
tugberk
53.8k5858 gold badges230230 silver badges320320 bronze badges
Using C# and WPF under .NET (rather than Windows Forms or console), what is the correct way to create an application that can only be run as a single instance?
I know it has something to do with some ...
asked Aug 21 '08 at 0:33
Nidonocu
11.6k66 gold badges3838 silver badges4242 bronze badges
Let's discuss following topic. There is application which currently is being deployed with good to know xcopy method.This approach makes difficult to manage dependencies, file updates etc. There is ...
asked Jul 28 '14 at 20:57
Vadym Fedorov
2,27722 gold badges2020 silver badges3131 bronze badges
How do I enable assembly bind failure logging (Fusion) in .NET?
asked Nov 1 '08 at 8:58
user32736
9,47133 gold badges1616 silver badges66 bronze badges
Given a DateTime representing a person's birthday, how do I calculate their age in years?
When planning out my programs, I often start with a chain of thought like so:
A football team is just a list of football players. Therefore, I should represent it with:
var football_team = new ...
asked Feb 11 '14 at 3:01
Superbest
21.9k1111 gold badges5353 silver badges128128 bronze badges
Is there any way to run command prompt commands from within a C# application? If so how would I do the following:
copy /b Image1.jpg + Archive.rar Image2.jpg
This basically embeds an RAR file ...
asked Sep 24 '09 at 4:24
user
14.5k2727 gold badges7676 silver badges9595 bronze badges
I'm trying to convert some strings that are in French Canadian and basically, I'd like to be able to take out the French accent marks in the letters while keeping the letter. (E.g. convert é to e, so ...
asked Oct 30 '08 at 2:07
James Hall
5,65866 gold badges2424 silver badges2727 bronze badges
I have a TextBoxD1.Text and I want to convert it to an int to store it in a database.
How can I do this?
asked Jun 19 '09 at 20:02
turki2009
7,01922 gold badges1616 silver badges77 bronze badges
How do I read an embedded resource (text file) using StreamReader and return it as a string? My current script uses a Windows form and textbox that allows the user to find and replace text in a text ...
asked Jul 22 '10 at 22:51
Me.Close
7,63144 gold badges1414 silver badges66 bronze badges
I'm a C#/Windows Forms programmer with more than 5 years experience. I've been investigating WPF using the MVVM (Model-View-ViewModel) design pattern. I have searched the Internet for tutorials. I ...
asked Sep 10 '09 at 14:49
JP Richardson
35.7k3434 gold badges117117 silver badges150150 bronze badges
I have a windows forms app with a textbox control that I want to only accept integer values. In the past I've done this kind of validation by overloading the KeyPress event and just removing ...
asked Jan 20 '09 at 21:55
Mykroft
12.3k1313 gold badges4141 silver badges7171 bronze badges
I have following C# code in a console application.
Whenever I debug the application and run the query1 (which inserts a new value into the database) and then run query2 (which displays all the ...
asked Jun 17 '13 at 12:14
Joe Slater
2,37366 gold badges2828 silver badges4747 bronze badges
I've recently started to use the Entity Framework 4.0 in my .NET 4.0 application and am curious about a few things relating to pooling.
Connection pooling as I know is managed by the ADO.NET data ...
asked Sep 6 '10 at 16:42
Noldorin
134k5353 gold badges249249 silver badges293293 bronze badges
I installed my windows service via (name of the service: Testing Service)
InstallUtil.exe present in .NET Framework
(:\Windows\Microsoft.NET\FrameWork64\v4) in a windows 7 computer.
I can see my ...
asked May 8 '18 at 2:43
Sharpeye500
7,8332323 gold badges8080 silver badges135135 bronze badges
Is there any scenario where writing method like this:
public async Task<SomeResult> DoSomethingAsync()
{
// Some synchronous code might or might not be here... //
return await ...
asked Sep 30 '13 at 15:30
TX_
4,15633 gold badges2424 silver badges3939 bronze badges
I saw this post:
Typos… Just use option strict and explicit please.. during one software development project, which I was on as a consultant, they were getting ridiculous amounts of errors ...
asked Mar 16 '10 at 13:15
yretuta
7,5741616 gold badges7171 silver badges143143 bronze badges
Is there a free or open source library to read Excel files (.xls) directly from a C# program?
It does not need to be too fancy, just to select a worksheet and read the data as strings. So far, I've ...
asked Aug 19 '08 at 7:23
dbkk
11.9k1313 gold badges5050 silver badges5858 bronze badges
The title is kind of obscure. What I want to know is if this is possible:
string typeName = <read type name from somwhere>;
Type myType = Type.GetType(typeName);
MyGenericClass<myType> ...
Is there a simple out of the box way to impersonate a user in .NET?
So far I've been using this class from code project for all my impersonation requirements.
Is there a better way to do it by using ...
asked Sep 24 '08 at 3:55
ashwnacharya
13.8k2121 gold badges8282 silver badges111111 bronze badges
I've got a WCF service that passes around status updates via a struct like so:
[DataContract]
public struct StatusInfo
{
[DataMember] public int Total;
[DataMember] public string Authority;
}
...
asked May 9 '09 at 3:04
Paul Alexander
30.7k1414 gold badges9393 silver badges145145 bronze badges
Is it possible to embed a pre-existing DLL into a compiled C# executable (so that you only have one file to distribute)? If it is possible, how would one go about doing it?
Normally, I'm cool with ...
asked Oct 9 '08 at 23:11
Merus
8,17655 gold badges2626 silver badges4040 bronze badges
I have a condition in a silverlight application that compares 2 strings, for some reason when I use == it returns false while .Equals() returns true.
Here is the code:
if (((ListBoxItem)lstBaseMenu....
asked May 2 '09 at 13:36
Drahcir
10.9k1818 gold badges5858 silver badges7575 bronze badges
How do I convert a string to a byte[] in .NET (C#) without manually specifying a specific encoding?
I'm going to encrypt the string. I can encrypt it without converting, but I'd still like to know ...
asked Jan 23 '09 at 13:39
Agnel Kurian
53.4k3838 gold badges134134 silver badges209209 bronze badges
I am new to asynchronous programming with the async modifier. I am trying to figure out how to make sure that my Main method of a console application actually runs asynchronously.
class Program
{
...
asked Feb 9 '12 at 10:13
danielovich
7,74977 gold badges2323 silver badges2828 bronze badges
When I start a new ASP.NET project in Visual Studio, I can create an ASP.NET Web Application or I can create an ASP.NET Web Site.
What is the difference between ASP.NET Web Application and ASP.NET ...
asked Dec 29 '08 at 16:24
Robert S.
24.7k1212 gold badges8181 silver badges114114 bronze badges
What are the differences in implementing interfaces implicitly and explicitly in C#?
When should you use implicit and when should you use explicit?
Are there any pros and/or cons to one or the other?...
asked Sep 27 '08 at 10:56
Seb Nilsson
24.7k2929 gold badges9494 silver badges123123 bronze badges