Can someone translate this VB to C# (easy one)

Amaltok

New Member
I have the following function I use in VB all the time and am trying to learn C# and need to do the same thing in C#. Can anyone tell me what the equivalent would be?<BR><BR>Function fixQuotes(ByVal theString)<BR> fixQuotes = theString.Replace("'", "''")<BR>End Function<BR><BR>TIAI'm not a C# expert, but it looks like a function to replace commas in the variable theString with a single quotation mark.<BR><BR>VB and/or VB.Net both support the Replace method.<BR><BR>The code would be:<BR><BR>Private Function fixQuotes(byVal theString)as String<BR><BR> fixQuotes = theString.Replace(",","'")<BR><BR>End Function<BR><BR>The string value theString is passed into the function, any commas are replaced with a single quotation mark and the result if returned as the value fixQuotes. The function call might look like:<BR><BR> strRevised = fixQuotes(theString)<BR><BR>Hope this helps.<BR><BR>ttThe code that is there is VB and it works (it replaces a single apostrophe with a two apostrophes for inserting records into databases and whatnot)Hi there.... try this one..<BR><BR> public string fixQuotes(string theString)<BR> { <BR> theString = theString.Replace("'", "''") ;<BR> return theString;<BR> }<BR>any probs e-mail me: [email protected].
 
Back
Top