Check if a string contains an element from a list (of strings)

For the following block of code: For I = 0 To listOfStrings.Count – 1 If myString.Contains(lstOfStrings.Item(I)) Then Return True End If Next Return False The output is: Case 1: myString: C:\Files\myfile.doc listOfString: C:\Files\, C:\Files2\ Result: True Case 2: myString: C:\Files3\myfile.doc listOfString: C:\Files\, C:\Files2\ Result: False The list (listOfStrings) may contain several items (minimum 20) and … Read more

Setting Objects to Null/Nothing after use in .NET

Should you set all the objects to null (Nothing in VB.NET) once you have finished with them? I understand that in .NET it is essential to dispose of any instances of objects that implement the IDisposable interface to release some resources although the object can still be something after it is disposed (hence the isDisposed … Read more

Is there a way to navigate to real implementation of method behind an interface?

In Visual Studio, when you right-click a method call, you go to the implementation of that method inside a class except if you access this method through an interface: in that case you go to the interface method not to the actual implementation. Is there a way / tips (key shortcut or anything) to access … Read more

.NET Global exception handler in console application

Question: I want to define a global exception handler for unhandled exceptions in my console application. In asp.net, one can define one in global.asax, and in windows applications /services, one can define as below AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyExceptionHandler); But how can I define a global exception handler for a console application … Read more

Get the generated SQL statement from a SqlCommand object?

I have the following code: Using cmd As SqlCommand = Connection.CreateCommand cmd.CommandText = “UPDATE someTable SET Value = @Value” cmd.CommandText &= ” WHERE Id = @Id” cmd.Parameters.AddWithValue(“@Id”, 1234) cmd.Parameters.AddWithValue(“@Value”, “myValue”) cmd.ExecuteNonQuery End Using I wonder if there is any way to get the final SQL statment as a String, which should look like this: UPDATE … Read more

.Net Data structures: ArrayList, List, HashTable, Dictionary, SortedList, SortedDictionary — Speed, memory, and when to use each? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 11 months ago. Improve this question .NET has a lot of complex data structures. Unfortunately, some of them are quite similar … Read more