StateBag.Count Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
The number of items in the StateBag.
The following code example demonstrates using the Count property.
private string GetMruList(string selectedValue) {
StateBag state = ViewState;
if (state.Count > 0) {
int upperBound = state.Count;
string[] keys = new string[upperBound];
StateItem[] values = new StateItem[upperBound];
state.Keys.CopyTo(keys, 0);
state.Values.CopyTo(values, 0);
StringBuilder options = new StringBuilder();
for(int i = 0; i < upperBound; i++) {
options.AppendFormat("<option {0} value={1}>{2}", (selectedValue == keys[i])?"selected":"", keys[i], values[i].Value);
}
return options.ToString();
}
return "";
}
Private Function GetMruList(selectedValue As String) As String
Dim state As StateBag = ViewState
If state.Count > 0 Then
Dim upperBound As Integer = state.Count
Dim keys(upperBound) As String
Dim values(upperBound) As StateItem
state.Keys.CopyTo(keys, 0)
state.Values.CopyTo(values, 0)
Dim options As New StringBuilder()
Dim i As Integer
For i = 0 To upperBound - 1
options.AppendFormat("<option {0} value={1}>{2}",IIf(selectedValue = keys(i), "selected", ""), keys(i), values(i).Value)
Next i
Return options.ToString()
End If
Return ""
End Function 'GetMruList
Produkt | Versjoner |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Samarbeid med oss på GitHub
Du finner kilden for dette innholdet på GitHub. Der du også kan opprette og se gjennom problemer og pull-forespørsler. Hvis du vil ha mer informasjon, kan du se vår bidragsyterveiledning.
.NET-tilbakemelding
.NET er et åpen kilde-prosjekt. Velg en kobling for å gi tilbakemelding: