Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

WebTestContext::TryGetValue Method (String^, Object^)

 

Gets the value associated with the specified key.

Namespace:   Microsoft.VisualStudio.TestTools.WebTesting
Assembly:  Microsoft.VisualStudio.QualityTools.WebTestFramework (in Microsoft.VisualStudio.QualityTools.WebTestFramework.dll)

public:
virtual bool TryGetValue(
	String^ key,
	[OutAttribute] Object^% value
) sealed

Parameters

key
Type: System::String^

The key to find.

value
Type: System::Object^

The referenced object that retrieves the value of the key, if it is found; otherwise, it retrieves the default value for the type of the value parameter. This parameter can be passed uninitialized.

Return Value

Type: System::Boolean

true if it contains an element with the specified key; otherwise, false.

Exception Condition
ArgumentNullException

key is null.

Context defined by environmental variables or a load test will override the item returned by this property. So if a Web performance test is running in a load test that contains a context called "myContext", a call to MyWebTestContext.TryGetValue("myContext", MyObject) will return the value for the LoadTestContext.Item("myContext", MyObject).

This is the most efficient way to try to retrieve values if several tried keys are not in the dictionary. This method combines the functionality of the ContainsKey method and the Item property.

If the key is not found, the out value parameter receives the appropriate default value: zero for integer types, false for Boolean types, and null for reference types.

Return to top
Show: