本文整理汇总了C#中System.Collections.Specialized.NameValueCollection.GetValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.GetValueOrDefault方法的具体用法?C# NameValueCollection.GetValueOrDefault怎么用?C# NameValueCollection.GetValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.NameValueCollection
的用法示例。
在下文中一共展示了NameValueCollection.GetValueOrDefault方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: can_get_empty_boolean_from_form
public void can_get_empty_boolean_from_form()
{
var collection = new NameValueCollection { { "text", "blah" } };
var value = collection.GetValueOrDefault("radio", CollectionUtilities.GetFlexibleBooleanParsingFunction());
Expect(value, Is.False);
}
示例2: throws_invalidoperationexception_when_lookup_has_multiple_values
public void throws_invalidoperationexception_when_lookup_has_multiple_values()
{
var collection = new NameValueCollection { { "state", "CA" }, { "state", "BC" } };
Expect(() => collection.GetValueOrDefault<string>("state"), Throws.InvalidOperationException);
}
示例3: flexible_boolean_parsing_is_case_insensitive
public void flexible_boolean_parsing_is_case_insensitive()
{
var collection = new NameValueCollection { { "question", "YES" } };
var value = collection.GetValueOrDefault("question", CollectionExtensions.GetFlexibleBooleanParsingFunction("yes"));
Expect(value, Is.True);
}
示例4: can_get_boolean_from_form
public void can_get_boolean_from_form()
{
var collection = new NameValueCollection { { "radio", "on" } };
var value = collection.GetValueOrDefault("radio", CollectionExtensions.GetFlexibleBooleanParsingFunction());
Expect(value, Is.True);
}
示例5: Can_get_value_from_settings
public void Can_get_value_from_settings()
{
var settings = new NameValueCollection { { "butter", "300" } };
var result = settings.GetValueOrDefault("butter", 1);
result.Should().Be(300);
}
示例6: Can_get_default_if_settings_doesnt_exist
public void Can_get_default_if_settings_doesnt_exist()
{
var settings = new NameValueCollection();
var result = settings.GetValueOrDefault("butter", 1);
result.Should().Be(1);
}