यदि आप मतलब है, "उपयोगकर्ता एक मूल्य निर्दिष्ट करना होगा" तो निर्माता के माध्यम से इसे बल:
public YourType(string documentType) {
DocumentType = documentType; // TODO validation; can it be null? blank?
}
public string DocumentType {get;private set;}
अब आप दस्तावेज़ प्रकार निर्दिष्ट किए बिना एक उदाहरण नहीं बना सकते हैं, और यह कर सकते हैं उस समय के बाद हटाया नहीं जाएगा। तुम भी set
अनुमति देते हैं लेकिन मान्य सकता है:
public YourType(string documentType) {
DocumentType = documentType;
}
private string documentType;
public string DocumentType {
get { return documentType; }
set {
// TODO: validate
documentType = value;
}
}
स्रोत
2012-05-29 06:53:17
"संपत्ति की आवश्यकता बनाने के लिए" का क्या मतलब है? –
"एक संपत्ति आवश्यक बनाने के लिए" का अर्थ है संपत्ति में मूल्य की आवश्यकता है जिसे इसे खाली नहीं छोड़ा जा सकता है। –