For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Answer:
5 Comments on “For each of the following statements, select Yes if the statement is true. Otherwise, select No.”
Hans Wernersays:
Two of those answers are plain wrong! I don’t know if the exam expects me to mark those answers but from a technical point of view, they should all be marked as “Yes”!
Here is a simple example which shows the real results:
using System;
namespace Test
{
[System.FlagsAttribute()]
public enum Group
{
User = 1,
Supervisor = 2,
Manager = 4,
Administrator = 8
}
public class User
{
public Group UserGroup { get; set; }
}
class Program
{
public static void Main(string[] args)
{
User user = new User();
Hans, you used a logical OR and hence the first question’s answer in still a ‘NO’ as the question asks whether a user can be a member of two groups ie. Group1 & Group2
Two of those answers are plain wrong! I don’t know if the exam expects me to mark those answers but from a technical point of view, they should all be marked as “Yes”!
Here is a simple example which shows the real results:
using System;
namespace Test
{
[System.FlagsAttribute()]
public enum Group
{
User = 1,
Supervisor = 2,
Manager = 4,
Administrator = 8
}
public class User
{
public Group UserGroup { get; set; }
}
class Program
{
public static void Main(string[] args)
{
User user = new User();
// Output: User, Supervisor
user.UserGroup = Group.User | Group.Supervisor;
Console.WriteLine(user.UserGroup);
// Output: True
user.UserGroup = Group.Administrator;
Console.WriteLine(user.UserGroup == Group.Administrator);
// Output: True
user.UserGroup = Group.Supervisor;
Console.WriteLine(user.UserGroup < Group.Administrator);
Console.ReadKey();
}
}
}
0
0
YES, YES, YES
I agree
1
0
Hans, you used a logical OR and hence the first question’s answer in still a ‘NO’ as the question asks whether a user can be a member of two groups ie. Group1 & Group2
1
1
FlagAttribute is the major point here.It allows to use few enum values. See here
https://docs.microsoft.com/en-us/dotnet/api/system.flagsattribute?view=netframework-4.8
So, the correct answers are yes,yes,yes.
0
0
Hans Werner seems to be right !
@see https://msdn.microsoft.com/de-de/library/system.flagsattribute%28v=vs.110%29.aspx
0
0