π Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
1. What is an enum in C#?
Answer:
Explanation:
An enum (enumeration) in C# is a value type defined by a set of named integral constants.
2. What is the default underlying type of an enum in C#?
Answer:
Explanation:
In C#, the default underlying type of an enum is 'int'.
3. How can you define an enum in C# with a different underlying type?
Answer:
Explanation:
The underlying type of an enum can be specified after the colon in the enum declaration.
4. Can an enum in C# contain duplicate values?
Answer:
Explanation:
Enums in C# cannot contain duplicate values. Each value in an enum must be unique.
5. How do you assign a specific value to an enum member in C#?
Answer:
Explanation:
Specific values can be assigned to enum members by using the equals sign followed by the value.
6. What is the first value of an enum in C# if no value is explicitly assigned?
Answer:
Explanation:
If no value is explicitly assigned to the first member of an enum, its value defaults to 0.
7. How can you convert an enum to its corresponding numeric value?
Answer:
Explanation:
An enum can be cast to its underlying type or converted using the Convert class.
8. How do you define a flag enum in C#?
Answer:
Explanation:
A flag enum is defined by applying the [Flags] attribute and usually assigning values as powers of two.
9. Can you use strings as enum values in C#?
Answer:
Explanation:
Enums in C# must be integral types; string values are not allowed.
10. What happens when you try to parse an invalid string to an enum in C#?
Answer:
Explanation:
Attempting to parse an invalid string to an enum using Enum.Parse will result in a runtime exception.
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment