FAQ - VB to C sharp net guide

Question
'Strings' is an ambiguous reference between 'Microsoft.VisualBasic.Strings' and 'System.Linq.Strings'
Answer

Ok so both of these referenced object libraries contain the Stings object. Soutions:

We can remove one of the references from our project (ideally we would like to get rid of the VisualBasic reference - that would make it more c# like.

We could just qualify the object libriaries so there is no ambiguity.

We need to keep the Linq refrences, How can we get rid of the VB references?

 

We may have code like the following:

Information.UBound(saSplitLine)
This can be replaced by:
saSplit.GetUpperBound(0)

 

or

Constants.vbCrLf as in

string[] saSplitLine = sText.Split(Constants.vbCrLf);

which can be replaced by:

char[] delimiters = new char[] { '\r', '\n' };
string[] saSplitLine = sText.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

 

Other conventions that may trap the experienced vb programmer

 

If you found this information useful, please share it!


This FAQ was last updated on 21 July 2011

Contact Information

To find out more about Ava solutions you can contact us in a number of ways:
Follow Us...