how to declare a method for a property
-
hi. in DateTime.Now , Now is a property. But when we set a dot after Now we can see a list of methods and properties, such as DateTime.Now.AddDay() , DateTime.Now.Date , DateTime.Now.AddMonth() how can I do it? thanks mehran
-
hi. in DateTime.Now , Now is a property. But when we set a dot after Now we can see a list of methods and properties, such as DateTime.Now.AddDay() , DateTime.Now.Date , DateTime.Now.AddMonth() how can I do it? thanks mehran
If you have looked carefully at the type returned by the Now property, you might have seen that it's a DateTime object, which has properties and methods. So if you want to create a property that "has methods" you just need to create a property that returns an object that has other properties and methods. Hope it helps.
I will use Google before asking dumb questions
-
If you have looked carefully at the type returned by the Now property, you might have seen that it's a DateTime object, which has properties and methods. So if you want to create a property that "has methods" you just need to create a property that returns an object that has other properties and methods. Hope it helps.
I will use Google before asking dumb questions
so thakns.
-
hi. in DateTime.Now , Now is a property. But when we set a dot after Now we can see a list of methods and properties, such as DateTime.Now.AddDay() , DateTime.Now.Date , DateTime.Now.AddMonth() how can I do it? thanks mehran
This is so simple! DateTime.Now is of type of class 'Date' which has itself different properties and methods! You can create a class, and add any methods or properties in that class. In an other class, now you may have a property of the latter class type.