0
0
C Sharp (C#)programming~10 mins

Built-in attributes (Obsolete, Serializable) in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to mark the class as obsolete.

C Sharp (C#)
[[1]("Use NewClass instead")]
public class OldClass
{
}
Drag options to blanks, or click blank then click option'
AObsolete
BSerializable
CNonSerialized
DDeprecated
Attempts:
3 left
💡 Hint
Common Mistakes
Using Serializable instead of Obsolete.
Trying to use Deprecated which is not a C# attribute.
2fill in blank
medium

Complete the code to make the class serializable.

C Sharp (C#)
[[1]]
public class Data
{
    public int Id;
}
Drag options to blanks, or click blank then click option'
ASerializable
BObsolete
CNonSerialized
DDataContract
Attempts:
3 left
💡 Hint
Common Mistakes
Using Obsolete instead of Serializable.
Confusing NonSerialized which is for fields, not classes.
3fill in blank
hard

Fix the error in the code to correctly mark the field as not serializable.

C Sharp (C#)
[Serializable]
public class User
{
    public string Name;
    [[1]]
    public string Password;
}
Drag options to blanks, or click blank then click option'
ASerializable
BNonSerialized
CObsolete
DIgnoreDataMember
Attempts:
3 left
💡 Hint
Common Mistakes
Using Serializable on a field inside a Serializable class.
Using Obsolete which is unrelated to serialization.
4fill in blank
hard

Fill both blanks to mark the class as obsolete and serializable.

C Sharp (C#)
[[1]("This class is outdated")]
[[2]]
public class OldData
{
    public int Value;
}
Drag options to blanks, or click blank then click option'
AObsolete
BSerializable
CNonSerialized
DDeprecated
Attempts:
3 left
💡 Hint
Common Mistakes
Using Deprecated which is not a valid C# attribute.
Mixing up NonSerialized which is for fields only.
5fill in blank
hard

Fill all three blanks to mark the class obsolete, make it serializable, and exclude a field from serialization.

C Sharp (C#)
[[1]("Use NewUser instead")]
[[2]]
public class User
{
    public string Username;
    [[3]]
    public string Password;
}
Drag options to blanks, or click blank then click option'
AObsolete
BSerializable
CNonSerialized
DDeprecated
Attempts:
3 left
💡 Hint
Common Mistakes
Using Deprecated which is not a C# attribute.
Forgetting to exclude sensitive fields from serialization.