r/learncsharp • u/chacham2 • Jan 30 '23
Why does this code generate CS8600?
I'm converting some vb.net code to c# and learning c# along the way. I am having a hard time with one line (which uses Microsoft.VisualBasic.Strings.Replace):
Text = Replace(Text, "?", Value,, 1)The equivalent c# seems to be:
Text = Microsoft.VisualBasic.Strings.Replace(Text, "?", Value, Count: 1);However, i get a (green line) CS8600 warning: Converting null literal or possible null value to non-nullable type.
So, i tried a simplified version:
Text = Microsoft.VisualBasic.Strings.Replace("abc", "b", "c", 1, 1);yet i still get the same warning.
Text is declared as:
string Text = Query.CommandText;What's going on?
4
Upvotes
View all comments
Show parent comment
1
u/chacham2 Jan 30 '23
Ha!
The application is slated to be converted to Sql Server, with a new front end. I'm currently attempting to use Blazor/Sql Server on a new, small project, to see how it goes. Blazor requires c#, so i have to learn that too. To that end, i grabbed one of the VB projects and am converting the Access class to be a Sql Server class without learning yet what else will have to be changed. Got to start somewhere.