| Reporter |
tobi (thymin)
|
|---|---|
| Created | Jan 14, 2012 9:47:15 PM |
| Updated | Jan 14, 2012 9:47:15 PM |
| Priority | Normal |
| Type | Unspecified |
| Fix versions | No Fix versions |
| State | Submitted |
| Assignee | Unassigned |
| Subsystem | No subsystem |
| Affected versions | No Affected versions |
| Fixed in build | No Fixed in build |
code:
public struct WordMatchStatistics
{
public string Word;
public int DocumentMatchCount;
public int FieldMatchCount;
public int OccurenceCount;
public WordMatchStatistics(string word, int documentMatchCount, int fieldMatchCount, int occurenceCount)
{
Word = word;
DocumentMatchCount = documentMatchCount;
FieldMatchCount = fieldMatchCount;
OccurenceCount = occurenceCount;
}
}
now encapsulate "Word" to an auto property. you get:
public struct WordMatchStatistics
{
public string Word { get; set; }
public int DocumentMatchCount;
public int FieldMatchCount;
public int OccurenceCount;
public WordMatchStatistics(string word, int documentMatchCount, int fieldMatchCount, int occurenceCount)
{
Word = word;
DocumentMatchCount = documentMatchCount;
FieldMatchCount = fieldMatchCount;
OccurenceCount = occurenceCount;
}
}
Which causes a compiler error (reference to this not yet allowed). In a struct you need:
public WordMatchStatistics(string word, int documentMatchCount, int fieldMatchCount, int occurenceCount)
: this() //<—-
{
public struct WordMatchStatistics
{
public string Word;
public int DocumentMatchCount;
public int FieldMatchCount;
public int OccurenceCount;
public WordMatchStatistics(string word, int documentMatchCount, int fieldMatchCount, int occurenceCount)
{
Word = word;
DocumentMatchCount = documentMatchCount;
FieldMatchCount = fieldMatchCount;
OccurenceCount = occurenceCount;
}
}
now encapsulate "Word" to an auto property. you get:
public struct WordMatchStatistics
{
public string Word { get; set; }
public int DocumentMatchCount;
public int FieldMatchCount;
public int OccurenceCount;
public WordMatchStatistics(string word, int documentMatchCount, int fieldMatchCount, int occurenceCount)
{
Word = word;
DocumentMatchCount = documentMatchCount;
FieldMatchCount = fieldMatchCount;
OccurenceCount = occurenceCount;
}
}
Which causes a compiler error (reference to this not yet allowed). In a struct you need:
public WordMatchStatistics(string word, int documentMatchCount, int fieldMatchCount, int occurenceCount)
: this() //<—-
{
tobi (thymin)