As John Simmons mentions, this is simply not valid C#. You have to follow the syntactical rules of the language. You don't simply get to make them up as you go along :)
That said, if you're using a recent version of C#, I am guessing you maybe want to do the following:
Name = string.IsNullOrEmpty(name) ? throw new Exception("Your Name cannot be 'Null'") : name;
Recent C# allows you to include throws with a ternary operator.
As an aside, it seems you are new to C#. The GetXXX/SetXXX pattern is more of a Java thing. You should probably look at how C# properties work. They formalize this pattern in the C# language.
private string name = "No Name";
public string Name
{
get => name;
set => name = value ?? throw new ArgumentNullException("Name");
}
Then, you can simply access the property
Name
as if its a variable within your code. Note, the code above only excludes null values. If you need to exclude empty values as well, you have a bit more coding to do.
While above remains correct for null values, for empty values you should consider throwing
ArgumentException
. It is generally not appropriate to simply throw
Exception
. There is almost always a more meaningful/specific exception. In the rare case there is not one, you should create your own by deriving from
Exception
.