I have to take \ r \ n
from the registry and compare it with another string, i.e. If it is not \ r \ n
or not, then check the variable.
Please look at this code, do not give it "TRUE" result. Please correct this problem.
class program {static void main (string [] args) {string check = "324214234 \ r \ n"; Registry Key RegKey = Registry.LocalMachine.CreateSubKey ("Software \\ MyRegkey \\ Settings \"); RegKey.SetValue ("ReceiveSplChar", @ "\ r \ n"); String value = regKey.GetValue ("ReceiveSplChar"). ToString (); If (Czech. Kantn (value) console. WrightLine ( "TRUE");}} : Here you enter the code in
string Prtyks value = regKey.GetValue ( "ReceiveSplChar") ToString () .; If (Prtyf value! = null) _arsiveedeta = _SetSerialPortkReadTo (credit value); Else _RCVData = _SetSerialPort .ReadLine (); if (SerialDataEvent! = nULL) {SerialDataEvent (_RCVData);}
special characters can be read his character is \ r \ n or \ t or \ u
Problem: In your first assignment Is considered as ( string Czech = "324214234 \ r \ n";
) you're not escape special characters so \ r \ n
as special characters and assigned string 324214234 & lt; newline & gt;
will, but your second assignment statement ( regKey.SetValue ( "ReceiveSplChar", @ "\ r \ n");
) Special characters with @
are saved so that the assigned string is intact 324214234 \ r \ n
Solution:
Replace it:
string check = "324214234 \ r \ n";
with:
string check = "324214234 \ r \ n"; Edit: If you use any of the following sample code ( \ r \ n, \ n, \ t
You can use: class program {static void Main (string [] args) {string str = "12345 \ t"; String finish symbol = GetEndingSymbol (str); } // a given string straight string GetEndingSymbol (String str) {end (if. Else if (str.IndexOf ( "\ n") & gt; = 0) "\ n"; Else if (str.IndexOf ( " \ T ") & gt; = 0)" \ t "; return" ";}}
Comments
Post a Comment