Suppose I wanted to reinstall the command line with flags and so on. Flags are of type bool, but the command line is a string of type "/ activeFlag". Is there a way to program a setter in C # that accepts a bool, but getter returns a string?
as
private string activeFlag { get { return activeFlag; } set { // the value here should be the bool activeFlag = value ? " /activeFlag" : ""; } }
You need a different setter.
private string activeFlag { get { return _activeFlag; } } private bool activeFlagByBool { set { // the value here should be the bool _activeFlag = value ? " /activeFlag" : ""; } }
There is no way to have a property with different data types for its setter and getter.
What you can do is something like this:
private bool IsActiveFlagSet { get { return ActiveFlag == " /activeFlag"; } } private string ActiveFlag { get; set; }
, TypeConverter , TypeDescriptor. . , , DataGridView, PropertyGrid .
TypeConverter
TypeDescriptor
DataGridView
PropertyGrid
; - . :
[CommandLine("/activeFlag")] public bool IsActive {get;set;}
?
, # , .
Source: https://habr.com/ru/post/1719608/More articles:Creating shared hash tables - C ++ - c ++Limit or limit the value used for the xsi attribute: type - xmlКак избавиться от предупреждения C4800, вызванного boost:: flyweight в VS2008 - c++How can I prevent a package-private interface appearing in Javadoc? - javawhy in this example we need both const and non-constant getters - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1719609/javascriptjquery-dtosobjects-to-hold-state&usg=ALkJrhi_DNNcbfjn6AxD6vHaKlcG85PUvAprevent height measurement during development - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1719611/why-does-creating-a-table-with-a-foreign-key-constraint-in-one-transaction-block-access-to-the-referenced-table-in-another&usg=ALkJrhgieZmiupiiXG7qMgaK5MPa1-v5ZAC # get Generic type specified by T - genericsHow unit test mail client - c ++All Articles