

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Optional property in a C# class
A property is optional if it is possible and valid for it to have null. A property whose CLR type cannot have null cannot be configured optional.
An example optional attribute usage −
Example
[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)] internal sealed class OptionalAttribute : Attribute { } public class Employee { public string EmpName { get; set; } [Optional] public string AlternativeName { get; set; } }
- Related Questions & Answers
- Java 8 Optional Class
- How to get a stream from Optional class in Java 9?
- What are the new methods added to an Optional class in Java 9?
- Optional chaining operator in JavaScript.
- Optional Parameters in Dart Programming
- Mandatory and optional Participation
- Handling optional/empty data in MongoDB?
- Explain Optional Catch Binding in JavaScript.
- Role of CSS :optional Selector
- How to pass optional parameters to a function in Python?
- What are optional arguments in JavaScript Functions?
- What is an Optional parameter in C#?
- How to make the argument optional in Python
- Newman Optional Parameters & Configurations using Postman
- How can I declare optional function parameters in JavaScript?
Advertisements