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

渭南专业做网站上海到北京

渭南专业做网站,上海到北京,淘宝做推广网站,网站建设 辉煌电商本文内容 使用 C# 索引器实现 C# 的 is 和 as 关键字实现 C# 的 lock 关键字 本节中的主题介绍如何在 Visual C 中创建程序集#xff0c;这些程序集使用或提供以 C# 或 Visual Basic 编写的程序集的功能。 1、使用 C# 索引器 Visual C 不包含索引器#xff1b;它具有索引…本文内容 使用 C# 索引器实现 C# 的 is 和 as 关键字实现 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 02、实现 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 string3、实现 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/14593063/

相关文章:

  • 网站策划书是什么厦门微网站建设
  • 厦门网站制作哪里好薇专业的销售网站
  • 网站不备案可以吗南昌网站建设开发团队
  • 寿光营销型网站建设交易网站建设
  • 企业门户网站建设思路百度网首页
  • 北京网站优化什么价格大型网络游戏排行榜前十
  • 吴江建设局房产网站兼职学网页设计怎么样
  • 金华网站建设方案开发自己架设网站
  • php语言入门seo助手
  • 南昌企业建设网站设计浅析企业网络营销推广方法
  • 做网站会后期维护吗无锡住房和城乡建设部网站
  • 十大ppt模板免费下载网站农业网站 源码
  • 门户网站是网络表达吗定制网站费用
  • 设计上海2023展会时间济宁优化推广公司
  • 江苏恒健建设集团有限公司网站京东网站项目建设规划书
  • 江苏省网站建设哪些网站做婚纱摄影
  • 西局网站建设谈谈我认为的网络营销是什么
  • 摄影网站建设策划书wordpress游客投稿
  • 免费网站建站系统电子商务网站建设实训报告文章
  • dedecms网站地图制作网络营销的特点举例说明
  • 做网站与网页有什么区别个人注册网址怎么注册
  • 网站建设的后期维护问题南京科技网站设计多少钱
  • 嘉兴网站推广wordpress更换IP
  • 贸易公司 网站 扶持广州房产网
  • 郑州模板建站系统网站建设 赚钱吗
  • 上饶专业的企业网站开发公司企业网站的推广阶段和特点
  • 北京高端网站建设工作wordpress视频类模板
  • 网站怎么排版删除自豪的采用wordpress
  • 放弃wordpress珠海百度推广优化排名
  • 简约的网站设计上海网络广告公司