我有这堂课:
public struct Escapes
{
private readonly string Value;
private Escapes(string value) => Value = value;
public static implicit operator string(Escapes r) => r.Value;
public override string ToString() => Value;
public static readonly Escapes LineFeed = new Escapes("\n");
public static readonly Escapes CarriageReturn = new Escapes(new Escapes("\r"));
public static readonly Escapes Digit = new Escapes(@"\d");
public static readonly Escapes NotADigit = new Escapes(@"\D");
public static readonly Escapes WordChar = new Escapes(@"\w");
//……………
public static Escapes AsciiChar(byte asciiCode)
{
return new Escapes( @"\x" + Convert.ToString(asciiCode, 16).PadLeft(2, '0'));
}
public static Escapes Unicode(short uniCode)
{
return new Escapes(@"\u" + Convert.ToString(uniCode, 16).PadLeft(4, '0'));
}
}
我也有这个课程:
public class CharOrEscape
{
public string Value;
private CharOrEscape(string value) => Value = value;
public static implicit operator CharOrEscape(Escapes s) => new CharOrEscape(s.ToString());
public static implicit operator CharOrEscape(char c) => new CharOrEscape(c.ToString());
public static implicit operator string(CharOrEscape s) => s.ToString();
public override string ToString() => Value;
public override bool Equals(object obj) => ((CharOrEscape)obj).Value == Value;
}
我想告诉intellisense,CharOrEscape
类型的任何属性或参数都接受Escapes类型的值,以便自动完成列表提供Escapes类的成员。
我曾经使用过某些属性看过这样的代码,但是我丢失了项目,谷歌搜索无法再找到它。
答案 0 :(得分:1)
如果我正确理解了请求,您可以使用类似的内容评论CharOrEscape
的属性
///<summary></summary>
///<typeparamref name="Escapes"/>
public string Value;
...
您可以在docs page
上阅读更多内容