CustomStrokes.Item 属性 (String)
获取 CustomStrokes 集合中具有指定名称的 Strokes 集合。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public ReadOnly Property Item ( _
name As String _
) As Strokes
用法
Dim instance As CustomStrokes
Dim name As String
Dim value As Strokes
value = instance.Item(name)
public Strokes Item[
string name
] { get; }
public:
property Strokes^ Item[String^ name] {
Strokes^ get (String^ name);
}
/** @property */
public Strokes get_Item(
String name
)
JScript 不支持索引属性。
参数
- name
类型:System.String
要从集合返回的 Strokes 集合的名称。
属性值
类型:Microsoft.Ink.Strokes
CustomStrokes 集合中的指定的 Strokes 集合。
备注
如果 name 与 CustomStrokes 集合的现有成员不匹配,则会引发 System.ArgumentException。
备注
在 C# 中,应按下例所示使用该集合的索引器,而不是使用该集合的 Item 属性。
示例
在此示例中,如果 Ink 对象的 CustomStrokes 集合包含具有指定名称的 Strokes 集合,则方法返回 true。如果没有具有指定名称的 Strokes 集合,则会引发异常,并且方法返回 false。
Private Function CustomStrokesCollectionExists(ByVal mName As String, ByVal mInk As Ink) As Boolean
Try
Dim S As Strokes = mInk.CustomStrokes(mName)
' In VB, you can also access the named collections by using the Item property:
' Dim S As Strokes = mInk.CustomStrokes.Item(mName)
'
' if the previous statement did not raise an exception,
' the named Strokes collection exists
Return True
Catch E As ArgumentException
' this exception is raised when the named collection does not exist
Catch E As Exception
' in case another type of exception is raised
End Try
Return False
End Function
private bool CustomStrokesCollectionExists(string mName, Ink mInk)
{
try
{
Strokes S = mInk.CustomStrokes[mName];
// In C#, the Item property is not available. The following won't compile:
// Strokes S = mInk.CustomStrokes.Item[mName];
// if the previous statement did not throw an exception,
// the named Strokes collection exists
return true;
}
catch (ArgumentException)
{
// this exception is raised when the named collection does not exist
}
catch (Exception)
{
// in case another type of exception is raised
}
return false;
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0