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

网站建设课的感想自己的网站如何让百度收录

网站建设课的感想,自己的网站如何让百度收录,wordpress文章调用标签,wordpress淘宝客个人中心本文内容 使用 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.yayakq.cn/news/593004/

相关文章:

  • 做网站是什么海淀网站建设多少钱
  • 装修公司网站模版河南建筑业城乡建设网站查询
  • 样本之家登录网站ios 软件开发
  • wordpress响应式网站模板下载wordpress修改菜单内容
  • 医疗网站搭建建站服务外贸
  • 2016企业网站建设方案虚拟主机建设二个网站
  • 网站升级维护中页面湘潭seo磐石网络
  • wordpress php配置文件站长网seo综合查询工具
  • 定制网站建设报价单网络服务器可提供的常见服务有什么服务
  • 章丘做网站公司郑州生活信息网
  • seo是指搜索引擎营销广州网站优化费用
  • 企业网站产品分类多怎么做seo企业网页制作哪个公司好
  • 怎样建网站步骤网址导航是什么软件
  • 现在有专业做海鲜的网站没有做网站需要多大带宽
  • 甘肃城乡建设局安全质量网站身高差效果图网站
  • 二手网站怎么做帮别人做网站犯法吗
  • 做一款网站网站负责人核验现场拍摄照片电子件
  • 文创产品设计网站推荐办公空间设计说明200字
  • 做网站用什么服务器会比较好wordpress优惠券自动使用
  • 百度商桥怎么和网站网站如何做网站征求意见专栏
  • 大蒜做营销型网站四川城乡建设厅官方网站
  • 网站设计培训班女频做的最好的网站
  • pc网站手机网站app可以做网站首页的图片
  • 网站模板建网站外贸网站建设wordpress
  • 手机看电视剧网站大全深圳建业公司怎么样
  • 外包做网站价格wordpress网站维护插件
  • 有没有做英语试题的网站长春网站怎么推广
  • 网站如何做国外推广苏州seo服务
  • 注册建设网站的公司网站在万网申请的域名_需要把万网的账户密码给做网站的吗
  • 天津建设工程评标专家网站学校asp网站