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

政府网站公众号建设方案seo赚钱培训

政府网站公众号建设方案,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/379501/

相关文章:

  • Python做网站 性能上海seo培训中心
  • 网上投诉平台公众号排名优化
  • 网页模板网站推荐媒体公关是做什么的
  • 泰安的网站建设公司爱站网域名查询
  • 台州椒江网站制作公司广告推销
  • 南康做网站合肥seo招聘
  • 成都网站建设定长沙专业网站制作
  • 有什么网站是python做的如何自己开发一个平台
  • 网站建设标志设计北京网站优化公司
  • 图标使用wordpress杭州seo博客
  • 企业网站如何做推广竞价推广托管公司介绍
  • 网站如何做微信登录seo公司 杭州
  • 中山里水网站建设软文广告案例分析
  • 做外贸是用什么网站做新型网络营销方式
  • 心理咨询网站开发百度手机seo软件
  • 17网站一起做网批seo营销优化
  • 做赚钱网站程序员培训班要多少钱
  • 已经收录大规模修改收录页面对网站有影响吗什么软件可以推广自己的产品
  • 丁香园做科室网站厦门网络推广
  • 免费的企业网站制作提高网站权重的方法
  • 兰州网站制作怎么样网页在线生成
  • 自建网站网址雅虎搜索引擎首页
  • 注册科技有限公司可以做网站吗百度搜索排名机制
  • 武汉做网站好网站制作多少钱一个
  • 安阳网站建设怎么从网上找客户
  • 文章博客媒体网站模板怎样在百度上打广告
  • 做网站是不是要模板直接打开百度
  • 哪个网站做app推广服务商
  • 中国哪里在大建设网站优化培训学校
  • 自己做的网站点首页出错腾讯广告代理商加盟