Linked Questions
30 questions linked to/from What is the { get; set; } syntax in C#?
55
votes
6
answers
118k
views
What does this mean ? public Name {get; set;} [duplicate]
I see this quiet often in C# documentation. But what does it do?
public class Car
{
public Name { get; set; }
}
0
votes
2
answers
7k
views
What does {get; set;} means ? [duplicate]
Consider the following code :
public class Order
{
public int OrderID { get; set; }
public DateTime OrderDate { get; set; }
public decimal Total { get; set; }
}
I ...
0
votes
2
answers
5k
views
declare function without parentheses in c# [duplicate]
I have seen a singletone code that uses a function without parentheses. i wanted to know is there any difference between a function without parentheses and a function with parentheses that takes no ...
-1
votes
1
answer
4k
views
What is the difference between properties and fields? [duplicate]
Hello what is difference between this field:
public string Name;
And this property:
public string Name{get;set;}
I read this topic :
What is the { get; set; } syntax in C#?
-5
votes
1
answer
281
views
Can anyone explain the below code? [duplicate]
using System;
class Program
{
class Person {
protected int Age {get; set;}
protected string Name {get; set;}
}
class Student : Person {
public Student(string nm) {
...
0
votes
1
answer
173
views
Singleton class crash when set an attribut with no exception [duplicate]
I have an strange comportement with my singleton class.
public class HttpCommunicator{
public const int TYPEJSON = 1;
private static HttpCommunicator;
private bool TypeIsInit = false;
...
0
votes
1
answer
266
views
Get Set vs Get Set with variable, difference? [duplicate]
What is the difference between the following, and why would I choose the one above the other?
public string MyProperty { get; set; }
VS
public string MyProperty
{
get { return _myProperty; }
...
0
votes
1
answer
243
views
Cannot set variable of class (C#) [duplicate]
I am trying to set a variable in a class that I created.
public class Star
{
public int starID { get; set; }
public Vector3 position { get; set; }
public string ...
0
votes
0
answers
57
views
Use short hand/automatic {get;set} in class instead of making the varibale public [duplicate]
I'm fairly new to C# and I'm following this tutorial.
I've reached the part about get and set of private instances (using theirs example)
class Person
{
private string name; // field
public string ...
5
votes
13
answers
4k
views
What is the difference...? [C# properties GET/SET ways]
I know in C# you can easily create accessors to a data type, for example, by doing the following:
public class DCCProbeData
{
public float _linearActual { get; set; }
public float ...
3
votes
4
answers
15k
views
How get set property works in C#?
I am new to C# and am exploring the very basic of C# get and set properties. What I have found is, The get set accessor or modifier mostly used for storing and retrieving value from the private field. ...
3
votes
2
answers
2k
views
Beginner RPG efficient ASCII map and movement system
Since your help with my first issue, I have made some great progress with the RPG I'm making for both educational and recreational purposes. Thank you all for that!
In this post, I will be asking for ...
1
vote
2
answers
3k
views
C# property set if
Can I make a property in c# class that has no field, but I still can check the value and set it only if match?
I mean something like this:
public int Num
{
get;
set if value > 0 &&...
0
votes
2
answers
2k
views
Multiply Value in Set Backing Field in C#
I'm looking to multiply a value in the set backing field in C# (for an ASP.NET MVC application). I'm doing this to avoid issues with dividing floating point numbers and therefore the properties are ...
1
vote
1
answer
4k
views
Using a Public Integer Variable as a Counter C#
I'm creating a Pokemon-type game in Visual Studio. I'm working on the Inventory form right now.
My question is can I use a public count variable as a way to keep track of the inventory?
Setting ...