当前位置: 首页 > news >正文

百度数据平台恩城seo的网站

百度数据平台,恩城seo的网站,asp网站优化访问速度,高端seo服务本文内容 使用 C# 索引器实现 C# 的 is 和 as 关键字实现 C# 的 lock 关键字 本节中的主题介绍如何在 Visual C 中创建程序集,这些程序集使用或提供以 C# 或 Visual Basic 编写的程序集的功能。 1、使用 C# 索引器 Visual C 不包含索引器;它具有索引…

本文内容

  1. 使用 C# 索引器
  2. 实现 C# 的 is 和 as 关键字
  3. 实现 C# 的 lock 关键字

本节中的主题介绍如何在 Visual C++ 中创建程序集,这些程序集使用或提供以 C# 或 Visual Basic 编写的程序集的功能。

1、使用 C# 索引器

Visual C++ 不包含索引器;它具有索引属性。 若要使用 C# 索引器,请访问索引器,就像它是索引属性一样。

示例

以下 C# 程序定义索引器。

// consume_cs_indexers.cs
// compile with: /target:library
using System;
public class IndexerClass {private int [] myArray = new int[100];public int this [int index] {   // Indexer declarationget {// Check the index limits.if (index < 0 || index >= 100)return 0;elsereturn myArray[index];}set {if (!(index < 0 || index >= 100))myArray[index] = value;}}
}
/*
// code to consume the indexer
public class MainClass {public static void Main() {IndexerClass b = new IndexerClass();// Call indexer to initialize elements 3 and 5b[3] = 256;b[5] = 1024;for (int i = 0 ; i <= 10 ; i++)Console.WriteLine("Element #{0} = {1}", i, b[i]);}
}
*/

此 C++/CLI 程序使用索引器。

// consume_cs_indexers_2.cpp
// compile with: /clr
#using "consume_cs_indexers.dll"
using namespace System;int main() {IndexerClass ^ ic = gcnew IndexerClass;ic->default[0] = 21;for (int i = 0 ; i <= 10 ; i++)Console::WriteLine("Element #{0} = {1}", i, ic->default[i]);
}

此示例产生以下输出:

Element #0 = 21
Element #1 = 0
Element #2 = 0
Element #3 = 0
Element #4 = 0
Element #5 = 0
Element #6 = 0
Element #7 = 0
Element #8 = 0
Element #9 = 0
Element #10 = 0

2、实现 C# 的 is 和 as 关键字

本主题演示如何在 Visual C++ 中实现 C# 的 is 和 as 关键字的功能。

示例

// CS_is_as.cpp
// compile with: /clr
using namespace System;interface class I {
public:void F();
};ref struct C : public I {virtual void F( void ) { }
};template < class T, class U >
Boolean isinst(U u) {return dynamic_cast< T >(u) != nullptr;
}int main() {C ^ c = gcnew C();I ^ i = safe_cast< I ^ >(c);   // is (maps to castclass in IL)I ^ ii = dynamic_cast< I ^ >(c);   // as (maps to isinst in IL)// simulate 'as':Object ^ o = "f";if ( isinst< String ^ >(o) )Console::WriteLine("o is a string");
}

输出结果:

o is a string

3、实现 C# 的 lock 关键字

本主题演示如何在 Visual C++ 中实现 C# lock 关键字。

示例

// CS_lock_in_CPP.cpp
// compile with: /clr
using namespace System::Threading;
ref class Lock {Object^ m_pObject;
public:Lock( Object ^ pObject ) : m_pObject( pObject ) {Monitor::Enter( m_pObject );}~Lock() {Monitor::Exit( m_pObject );}
};ref struct LockHelper {void DoSomething();
};void LockHelper::DoSomething() {// Note: Reference type with stack allocation semantics to provide// deterministic finalizationLock lock( this );// LockHelper instance is locked
}int main()
{LockHelper lockHelper;lockHelper.DoSomething();return 0;
}

 

 

http://www.hkea.cn/news/198959/

相关文章:

  • 网站域名被黑国际新闻最新消息战争
  • 苏州网站开发公司济南兴田德润厉害吗网络自动推广软件
  • 广药网站建设试卷株洲最新今日头条
  • 网站建设管理考核办法微信推广平台怎么做
  • 网站新闻模块代码网络推广有哪些常见的推广方法
  • 合肥大型网站如何推广普通话
  • 高端网站制作软件怎么样推广自己的店铺和产品
  • 无障碍浏览网站怎么做关键词seo排名优化推荐
  • wordpress 247seo推广系统
  • 做深圳门户网站起什么名字好泰州seo外包公司
  • 网站视频上传怎么做百度站长平台论坛
  • wordpress农业模板下载小时seo
  • 做网站语言排名2018发帖推广哪个平台好
  • 销氪crmseo入门讲解
  • 蒙阴哪有做淘宝网站的钓鱼网站制作教程
  • 网站如何做导航条下拉菜单怎么做百度网页
  • 网站开发都做什么平台推广精准客源
  • 网站建设共享ip宁波seo搜索引擎优化
  • 学校网站建设必要性搜索引擎排名
  • 哪里有做区块链网站的百度网址大全在哪里找
  • 加盟平台网站怎么做竞价托管多少钱一个月
  • wordpress 微信 代码网站关键词怎么优化排名
  • 网站推广维护考研培训班哪个机构比较好
  • 网站后台生成器人工智能培训班收费标准
  • 在线做app的网站武汉网络营销公司排名
  • 了解深圳网站页面设计潍坊百度关键词优化
  • 制作网站怎样找公司来帮做seo词条
  • 网络销售有哪些站长工具seo排名
  • 做房产中介网站怎么注册一个自己的网站
  • 天津网站设计成功柚米全网推广成功再收费