I was going through the source code for StreamReader
where I found -
public override int Read([In, Out] char[] buffer, int index, int count)
{
}
Can some one please shed some light on what the [In , Out]
thing of the first parameter means?
I was going through the source code for StreamReader
where I found -
public override int Read([In, Out] char[] buffer, int index, int count)
{
}
Can some one please shed some light on what the [In , Out]
thing of the first parameter means?
They are attributes (parameter attributes) having [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
The target of an attribute is the entity to which the attribute applies. For example, an attribute may apply to a class, a particular method, or an entire assembly. By default, an attribute applies to the element that it precedes. But you can also explicitly identify, for example, whether an attribute is applied to a method, or to its parameter, or to its return value.
-referenced from here
InAttribute
and OutAttribute
has been defined like this:
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class InAttribute : Attribute
{
internal static Attribute GetCustomAttribute(RuntimeParameterInfo parameter)
{
return parameter.IsIn ? new InAttribute() : null;
}
internal static bool IsDefined(RuntimeParameterInfo parameter)
{
return parameter.IsIn;
}
public InAttribute()
{
}
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class OutAttribute : Attribute
{
internal static Attribute GetCustomAttribute(RuntimeParameterInfo parameter)
{
return parameter.IsOut ? new OutAttribute() : null;
}
internal static bool IsDefined(RuntimeParameterInfo parameter)
{
return parameter.IsOut;
}
public OutAttribute()
{
}
}
Look at here on referencesource.microsoft.com for more detail on those attribute classes.