Click here to Skip to main content
15,887,240 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
Hai,


I am having doubt in flag.plz tell me what is the use of flag in .net and why we used it.
Posted
Comments
Prerak Patel 24-Mar-11 5:54am    
It's not just .Net, flags are used in all the languages. They are just to check the conditions.
Sergey Alexandrovich Kryukov 24-Mar-11 12:49pm    
Do your mean System.FlagsAttribute, [Flags]?
--SA
Boothalingam 5-Sep-12 5:31am    
not Understand Anything

Flag variable(s) are the notification value, which can be read by its intended user modules, to get the required notification to continue or to stop the process. Conditionally the value of flag is changed by only one process and read by other.
Flags are mostly in boolean, but it also depends upon the scenarios, where it can be even numeric or even in characters.
 
Share this answer
 
It's also a possible attribute for enumerators :

C#
[Flags]
public enum MyProperties { None=0, Left=1, Right=2, Center=4, Top=8, Bottom=16, Middle=32, All=64 }


Go here for a complete example (and scroll down to the section labeled Enumeration Types as Bit Flags)

http://msdn.microsoft.com/en-us/library/cc138362.aspx[^]
 
Share this answer
 
A flag is just a boolean variable used to indicate a particolar condition, for instance
bool done;


done might be false while an operation is still in progress and become true after the operation is completed.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900