Last active
July 27, 2025 22:06
-
-
Save amirrajan/94c0e3ef4a9275838cdf2a7daf8d8792 to your computer and use it in GitHub Desktop.
"Clever" C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person | |
{ | |
private string _firstName; | |
private string _lastName; | |
public Person(string lastName) | |
{ | |
_firstName = "None"; | |
_lastName = _lastName; | |
} | |
public string GetFirstName() | |
{ | |
return _firstName; | |
} | |
public void SetFirstName(string value) | |
{ | |
_firstName = value; | |
} | |
public string GetLastName() | |
{ | |
return _lastName; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person | |
{ | |
private string _firstName; | |
private string _lastName; | |
public Person(string lastName) | |
{ | |
_firstName = "None"; | |
_lastName = lastName; | |
} | |
public FirstName | |
{ | |
get { return _firstName; } | |
set { _firstName = value; } | |
} | |
public LastName | |
{ | |
get { return _lastName; } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person | |
{ | |
private string _lastName; | |
public Person(string lastName) | |
{ | |
FirstName = "None"; | |
_lastName = lastName; | |
} | |
public FirstName { get; set; } | |
public LastName { get { return _lastName }; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Person | |
{ | |
public Person(string lastName) | |
{ | |
LastName = lastName; | |
} | |
public string FirstName { get; set; } = "None" | |
public string LastName { get; private set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person(string lastName) | |
{ | |
public string FirstName { get; set; } = "None"; | |
public string LastName { get; private set; } = lastName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment