M
mp
before looping through the characters in a string i define a variable to
hold the character preceeding the current character
char PreceedingCharacter;
before assigning PreceedingCharacter, how do I check it's state?
I keep getting error:
Use of unassigned local variable 'PreceedingCharacter'
i've tried
if (PreceedingCharacter.Equals ( null))
if(PreceedingCharacter==null)
at end of loop i assign PreceedingCharacter = CurrentCharacter;
so after the first character is examined, it (PreceedingCharacter ) will be
assigned.
it appears i have to assign to ' ' when defining it(although it's not
actually true)
char PreceedingCharacter = ' ';
is that the only way?
thanks
mark
private void CheckQuote2(string InputString)
{
//char PreceedingCharacter = ' '; <<< not true but it works
char PreceedingCharacter; <<< true but it doesn't work
char CurrentCharacter;
for (int CharPos = 0; CharPos < InputString.Length; CharPos++)
{
CurrentCharacter=InputString[CharPos];
if (CurrentCharacter.ToString()== "\"")
{
if (_AmInQuote == true)
{
//if (PreceedingCharacter.Equals ( null))
//if(PreceedingCharacter==null)
//if (is null(PreceedingCharacter ))
if(CharPos > 0)
{
if (PreceedingCharacter.ToString() == "\\")
{
Debug.Print("this is an escaped quote
character inside a string");
}
}
}
else
{
_AmInQuote = false;
Debug.Print("End quote");
}
}
else
{
if (PreceedingCharacter.ToString() == "\\")
{
//this is an escaped quote character outside a
string
}
else
{
_AmInQuote = true;
Debug.Print("Start quote");
}
}
PreceedingCharacter = CurrentCharacter;
}//end for
}//end Check
hold the character preceeding the current character
char PreceedingCharacter;
before assigning PreceedingCharacter, how do I check it's state?
I keep getting error:
Use of unassigned local variable 'PreceedingCharacter'
i've tried
if (PreceedingCharacter.Equals ( null))
if(PreceedingCharacter==null)
at end of loop i assign PreceedingCharacter = CurrentCharacter;
so after the first character is examined, it (PreceedingCharacter ) will be
assigned.
it appears i have to assign to ' ' when defining it(although it's not
actually true)
char PreceedingCharacter = ' ';
is that the only way?
thanks
mark
private void CheckQuote2(string InputString)
{
//char PreceedingCharacter = ' '; <<< not true but it works
char PreceedingCharacter; <<< true but it doesn't work
char CurrentCharacter;
for (int CharPos = 0; CharPos < InputString.Length; CharPos++)
{
CurrentCharacter=InputString[CharPos];
if (CurrentCharacter.ToString()== "\"")
{
if (_AmInQuote == true)
{
//if (PreceedingCharacter.Equals ( null))
//if(PreceedingCharacter==null)
//if (is null(PreceedingCharacter ))
if(CharPos > 0)
{
if (PreceedingCharacter.ToString() == "\\")
{
Debug.Print("this is an escaped quote
character inside a string");
}
}
}
else
{
_AmInQuote = false;
Debug.Print("End quote");
}
}
else
{
if (PreceedingCharacter.ToString() == "\\")
{
//this is an escaped quote character outside a
string
}
else
{
_AmInQuote = true;
Debug.Print("Start quote");
}
}
PreceedingCharacter = CurrentCharacter;
}//end for
}//end Check