共用方式為


PrivateObject.SetField Method (String, BindingFlags, Object)

Sets a value for the field of the wrapped object, identified by name.

Namespace:  Microsoft.VisualStudio.TestTools.UnitTesting
Assembly:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)

Syntax

'Declaration
Public Sub SetField ( _
    name As String, _
    bindingFlags As BindingFlags, _
    value As Object _
)
public void SetField(
    string name,
    BindingFlags bindingFlags,
    Object value
)
public:
void SetField(
    String^ name, 
    BindingFlags bindingFlags, 
    Object^ value
)
member SetField : 
        name:string * 
        bindingFlags:BindingFlags * 
        value:Object -> unit
public function SetField(
    name : String, 
    bindingFlags : BindingFlags, 
    value : Object
)

Parameters

  • name
    Type: String

    The name of the field to set a value.

  • bindingFlags
    Type: BindingFlags
  • value
    Type: Object

    The value to set.

Exceptions

Exception Condition
ArgumentException

name is nulla null reference (Nothing in Visual Basic) or empty.

.NET Framework Security

See Also

Reference

PrivateObject Class

SetField Overload

Microsoft.VisualStudio.TestTools.UnitTesting Namespace