C#
For encaps ...
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
For encapsulation, you want to define auto-implemented property so that you cannot call the setter outside the class, but leave the getter available. Which of the given options describes the desired property?
public int Value {get; }
public int Value {get; set; }
int Value {public get; private set; }
public int Value {get; private set; }
private int Value {public get; set; }
Explanation
Get an explanation when it's available:
Subscribe
properties
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
Related Content
Среди перечисленных конструкций C# укажите объявление свойства
Какие из свойств объявлены корректно: using Systеm; nаmеsрасе Q { сlаss Nаmе { рubliс string А { рrivаtе sеt; gеt; } private string В { public sеt; public gеt; } privatе string x; рubliс string С { gеt { return x.ToString(); } } рubliс string D { sеt { x = value; } private get; } } }
В каких строках содержатся ошибки компиляции? public class Foo { private double field; public double A { get { return field + 10.0; } // 1 set { field = value - 10.0; } // 2 } public int B { get; private set; } // 3 } public static class Program { public static void Main() { Foo f = new Foo(); double a = f.A; // 4 int b = f.B; // 5 f.B = 10; // 6 } }
Укажите, какие свойства определены неверно? public class Foo { private int a; private int c; public int A { get { return a; } set { a = value; } } public int B { get { return 0; } } public int C { set { c = value; } } protected int D { get; set; } protected int E { get; private set; } protected int F { public get; set; } }
C
#
Quiz
Login to learn C#
or
Read more about
C# Quizzes
Follow CodeGalaxy
Mobile Beta
Send Feedback
Keep exploring
C# quizzes
Лямбда-выражения на платформе .Net могут существовать в виде:
Скомпилируется ли данный фрагмент кода успешно? private int GetID (string inputText) { if (inputText != "") return 1; else if (inputText == "") return 0; }
Для чего предназначен метод Finalize?
Поддерживает ли С# перегрузку методов на основе возвращаемого значения?
public abstract class A { public virtual string Print() { return "A"; } } public class B : A { public override new string Print() { return "B"; } } public class C : B { public string Print() { return "C"; } } Каков будет результат при выполнении следующего кода: A ac = new C(); Console.WriteLine(ac.Print());
Укажите отличия интерфейса от абстрактного класса
Sign Up Now
or
Subscribe for future quizzes
Login in to like
Login in to comment