Note that there are some explanatory texts on larger screens.

plurals
  1. POC# & Silverlight Basic Class Syntax with Get/Set Properties not working
    text
    copied!<p>I have a really, really simple class and I am tried to use the get/set properties but they just aren't working for me... I am sure it is the most obvious thing that I am over looking but I just can't see why they aren't working. I have checked out the code that utilizes this class and its fine that I can see. </p> <p>In the main code, if I type </p> <pre><code>Report r = new Report(); string str = "Taco"; r.displayName = str; </code></pre> <p>The report is declared alright and everything is set to empty strings or a new list or whatever the parameter's default is. But every time I ran this the displayName always remained blank after the code finished executing... </p> <p>so I tried putting a stop point in the Class displayName set property at set {_displayName = displayName;} and the value always passed in (displayName) was an empty string.... even though the string clearly says "Taco" in the main code.... I have no idea but I am sure its right in my face. If you need more code I can provide it... </p> <pre><code>Report r = new Report(); string str = "Taco"; r.setReportDisplayName(str); </code></pre> <p>But for some reason the above works. </p> <pre><code>public class Report { private string _reportPath = string.Empty; public string reportPath { get { return _reportPath; } set { _reportPath = reportPath; } } private string _displayName = string.Empty; public string displayName { get { return _displayName; } set { _displayName = displayName; } } private List&lt;parameter&gt; _parameters = new List&lt;parameter&gt;(); public List&lt;parameter&gt; parameters { get { return _parameters; } set { _parameters = parameters; } } public Report() { } public Report(string path, string display, List&lt;parameter&gt; param) { _reportPath = path; _displayName = display _parameters = param; } public void setReportDisplayName(string str) { _displayName = str; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload