c# - Gives different meaning in another scope -


here have part of code.in here got error.

error >>a local variable named 'msg' cannot declared in scope because give different meaning 'msg', used in 'parent or current' scope denote else

but use thing inside smshelper class.then scope

public class smshelper {     private string msg;     private string converttoisofromutf8(string msg, string to, string from)     {          string iso_msg = null;         if (from.equals("utf-8"))         {             system.text.encoding iso = encoding.getencoding("iso-8859-1");             system.text.encoding utf8 = encoding.utf8;              byte[] utfbytes = utf8.getbytes(msg);             byte[] isobytes = encoding.convert(utf8, iso, utfbytes);             string msg = iso.getstring(isobytes);         } 

the 3 lines marked <-- this below each represent declaration of separate variable, each having same name msg. conflict eachother.

private string msg; // <-- private string converttoisofromutf8(string msg // <-- {     // ...     if (from.equals("utf-8"))     {         // ...         string msg // <-- ,     } } 

the following work:

private string _msg; private string converttoisofromutf8(string msg, // ... {     // ...     if (from.equals("utf-8"))     {         // ...         _msg = iso.getstring(isobytes);     } } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -