.net

What is the difference between String.Empty and “” and null?

Possible Duplicate: What is the difference between String.Empty and Is "" equivalent to String.Empty? Which is preferred for initializing string values? ...

Regex for Money

I have asp:TextBox to keep a value of money, i.e. '1000', '1000,0' and '1000,00' (comma is the delimiter because of Russian standard). What ValidationExpression have I to use into appropriate asp:RegularExpressionValidator? I tried \d+\,\d{0,2} but it doesn't allows a number without decimal digits, e.g. just '1000'. ...

Is the LinkedList in .NET a circular linked list?

I need a circular linked list, so I am wondering if LinkedList is a circular linked list? ...

Why do both the abstract class and interface exist in .Net?

Why do both the abstract class and interface exist in .Net ( or in C# ) if we can achieve the interface feature by making all the members in the class as abstract. Is it because: Interface exists to have multiple inheritance It makes sense to have interface because object's CAN-DO feature should be placed in an interface rather base a...

How can I overcome the overhead of creating a List<T> from an IEnumerable<T>?

I am using some of the LINQ select stuff to create some collections, which return IEnumerable<T>. In my case I need a List<T>, so I am passing the result to List<T>'s constructor to create one. I am wondering about the overhead of doing this. The items in my collections are usually in the millions, so I need to consider this. I assume...

RemotePrintServer

Is there a way to print to a RemotePrintServer in .NET Windows Service? I'm reviewing a piece of code where a LocalPrintServer is used, but I need to be able to send the print jobs to a remote print server. Any ideas? ...

How do you configure and enable log4net for a stand-alone class library assembly?

Background I am writing a class library assembly in C# .NET 3.5 which is used for integration with other applications including third-party Commercial-Off-The-Shelf (COTS) tools. Therefore, sometimes this class library will be called by applications (EXEs) that I control while other times it will be called by other DLLs or applications ...

Choosing the right data structure for this problem: circular linked list, list, array or something else

The requirement I have is for every type T, I have a number of elements (between 1-30+) and at first I need random item, then I need the next, and when I reach the last item, it should return the first one and so on. So say T is Icon, and the collection is Images (instance). I want to have: // program start: Icon icon = RandomIcon();...

my code reading Excel file error

Hello everyone, I am using VSTS 2008 + C# + .Net 3.5 to read Excel file created by Excel 2007 (but saved as Excel 2003 xls format). Here is my code, when executing code adapter.Fill(cities), there is exception -- "OldDbException Could not find installable ISAM". Any ideas what is wrong? static void Main(string[] args) { string conn...

Tools for refactoring C# public fields into properties

I have a lot of C# code that uses public fields, and I would like to convert them to properties. I have Resharper, and it will do them one by one, but this will take forever. Does anyone know of an automated refactoring tool that can help with this? ...

Convert .Net ManagementBaseObject to ManagementObject

I am trying to use the following code to write out all processes started on a computer. My problem is that the EventArrived method is passed a EventArrivedEventArgs which has a NewEvent property of type ManagementBaseObject. This does not have a InvokeMethod method. Can I convert the NewEvent property to a ManagementObject some how, o...

Windows Forms: Change application mainwindow at runtime

Normally I would do Application.Run(myMainForm). But I want to do something like this: MyForm1 f = new MyForm1(); f.Close+=OnOpenOverviewWin(); Application.Run(f); void OnOpenOverviewWin() { MyOverViewForm f = new MyOverViewForm (); Application.Run(f); // i want to do this Application.NewMainWindow = f; // or something like that } ...

to do a substring using LINQ on a string, do I have to correct syntax?

Dim myString As String = "1234567890" Dim Part As String = "" Part = myString.Substring(2, 2) '34 Part = New String(myString.Skip(2).Take(2).ToArray) '34 This code work but the linq one take about 1300% more time than the substring. I have 2 questions Do I have the correct syntax(for LINQ)? Should I stick with the s...

Excel Question: Trying to access via .NET, Excel 2007 seems to be auto-encrypting files on SAVE

I'm trying to access a 2003 formatted Excel spreadsheet in .NET. I have the process completed, and it's pretty straight forward by accessing the sheet and process the data. It works perfectly. The only problem is that Office 2007 Excel is encrypting these documents. Now, it has some odd behaviors. It seems to be encrypting the documents...

duplicate assemblies in a clickonce deployment

Hi, I'm investiguating clickonce deployment for a .NET application. This application contains a duplicated sets a assemblies (in different folders). The reason is that this application embed an asp.net web site that is used in-process. The winform app and the web site a sharing a set of dll for business logic and core plumbing. Whe...

.NET Wrapper Class

Should a wrapper class be an instance class or a class with shared members? I need to create a wrapper class around a 3rdparty library, exposing just 2 functions and hiding all the complexity of the 3rd party class. ...

Correct way to have an endless wait

So I have a program that has a list of timers. Each of the timers has a tick event and lets just say for example, i have 10 timers started (all are in the List). What is the best way to sit forever (or until i tell it to stop)? Should I just have a while loop? foreach(Timer t in _timers) { t.Start(); } while(true) { Application....

Getting the ip-address

In C#: IPHostEntry IPHost = Dns.GetHostEntry(Dns.GetHostName()); for (int i = 0; i < IPHost.AddressList.Length; i++) { textBox1.AppendText("My IP address is: " + IPHost.AddressList[i].ToString() + "\r\n"); } In this code, the IPHostEntry variable contains all the IP addresses of the computer. Now, as far as I know, Windo...

what iPhone application that helps developer most?

I just bought an iPhone 3GS and wondering what applications that can help on .NET development. ...

NHibernate tries to create the same entity twice

Currently I have database with the following associations: One Client to Many Intakes One Intake to Many CaseManagements One CaseManagement to Many Interventions Client, Intake, CaseManagement are single classes per table Intervention is a class-hierarchy-per-table. Currently, if I do something like this: var client = new Client()...