Код: Выделить всё
internal class Indentation {
public int Indent {
get => indent;
set {
indent = value;
indentStr = new string(' ', Size * Indent);
}
}
int Size { get; set; }
string indentStr;
private int indent;
public Indentation(int Size = 4) {
this.Size = Size;
indentStr = new string(' ', Size * Indent);
}
public override string ToString() {
return indentStr;
}
static public Indentation operator --(Indentation indentation) {
indentation.Indent--;
return indentation;
}
static public Indentation operator ++(Indentation indentation) {
indentation.Indent++;
return indentation;
}
}
Код: Выделить всё
int i = 4;
Indentation indent = new();
Debug.WriteLine(($"{i}|{indent}|public class ... {{"));
Debug.WriteLine(($"{i++}|{indent++}|public class ... {{"));
Код: Выделить всё
4||public class ... {
4| |public class ... {
Есть ли способ заставить отступ печатать до приращения? Что-то не так при перегрузке операторов (я не смог найти ничего полезного, а документация Microsoft скудна)?
Подробнее: https://stackoverflow.com/questions/799 ... expected-o