public interface IMyCharManager { string getlow(string s); } public class CharManager : IMyCharManager { #region IMyCharManager 成员 public string getlow(string s) { throw new Exception("The method or operation is not implemented."); } #endregion }
使用 string a = "ASDFAS"; sting b = ((IMyCharManager)a).getlow(a);
string mystring=((Imyinterface)mystring1).myfunction();
{
string getlow(string s);
} public class CharManager : IMyCharManager
{
#region IMyCharManager 成员 public string getlow(string s)
{
throw new Exception("The method or operation is not implemented.");
} #endregion
}
string a = "ASDFAS";
sting b = ((IMyCharManager)a).getlow(a);
所以你最好用一个包装类来封装它。
public interface IMyInterface {...}public class StringWrapper : IMyInterface { private string _StrContent = string.Empty;
//以下实现string中的各种方法。
public int CompareTo(string strB) {
return _StrContent.CompareTo(strB);
} public bool Contains(string value) {
return _StrContent.Contains(value);
} ...
}
编译没有通过。是不是我的这种使用本来就是无法实现?
string a = "ASDFAS";
sting b = ((IMyCharManager)a).getlow(a);
你应该是
CharManager obj = new CharManager
string b=((IMyCharManager)obj).getlow(a)