.netʵÀý:ʹÓÃC++µ÷ÓÃC#µÄDLL
1 ´´½¨C# DLL£¬ÐèÒªÖ¸¶¨Ó¦ÓÃÀàÐÍΪ“Àà¿â”£¬´úÂ룺
namespace CSLib
{
public class Class1
{
private string name;
public string Name
{
get
{
return name;
}
set
{
name = "Your Name: " + value;
}
}
}
}
2 C++¿Í»§³ÌÐò£¬ÊǸö¿ØÖÆÌ¨Ó¦Ó㬴úÂ룺
#using "..\debug\CSLib.dll"
using namespace CSLib;
int _tmain(int argc, _TCHAR* argv[])
{
Class1 ^c = gcnew Class1();
c->Name = "zzj";
printf("%s\n", c->Name);
return 0;
}
3 ¼¸µãÒª¼Çס£º
1 ʹÓÃ#usingÒýÓÃC# DLL£¬¶ø²»ÊÇ#include¡£ÎÒ¾ÍÊÇÏ뵱ȻµÄʹÓÃÁ˺óÕߣ¬ËùÒÔÀË·ÑÁËÒ»ÉÏÎçµÄʱ¼ä£»
2 ±ðÍüÁËusing namespace CSLib£»
3 ʹÓÃC++/clrÓï·¨£¬²ÉÓÃÕýÈ·µÄ·ÃÎÊÍйܶÔÏ󣬼´£ºÊ¹ÓÃñ×Ó''^''£¬¶ø²»ÊÇÐÇÐÇ''*''¡£
Ïà¹ØÎĵµ£º
²úÆ·¼¸ÄêǰʹÓÃASP£¬ºóÀ´Éý¼¶µ½.Net 1.1£¬ÔÙÉý¼¶µ½2.0£¬Ò»Ö±¶¼ÓÐÓÃXSLTת»»XMLÉú³ÉÍøÒ³µÄ·½Ê½£¬ÉÔ΢ÕûÀíÏ¡£
XML file:
<?xml version="1.0" encoding="utf-8" ?>
<ric>
<catalog>
<book price ......
ίÍкÍʼþÔÚ .Net FrameworkÖеÄÓ¦Ó÷dz£¹ã·º£¬È»¶ø£¬½ÏºÃµØÀí½âίÍкÍʼþ¶ÔºÜ¶à½Ó´¥C#ʱ¼ä²»³¤µÄÈËÀ´Ëµ²¢²»ÈÝÒס£ËüÃǾÍÏñÊÇÒ»µÀ¼÷¶ù£¬¹ýÁËÕâ¸ö¼÷µÄÈË£¬¾õµÃÕæÊÇÌ«ÈÝÒ×ÁË£¬¶øÃ»ÓйýÈ¥µÄÈËÿ´Î¼ûµ½Î¯ÍкÍʼþ¾Í¾õµÃÐÄÀï±ð£¨bi裩µÃ»Å£¬»ìÉí²»×ÔÔÚ¡£±¾ÎÄÖУ¬ÎÒ½«Í¨¹ýÁ½¸ö·¶ÀýÓÉdzÈëÉîµØ½²ÊöʲôÊÇίÍС¢ÎªÊ²Ã´ÒªÊ¹Ó ......
Ò»£®ÀàÓë½á¹¹µÄʾÀý±È½Ï£º
½á¹¹Ê¾Àý£º
public struct Person
{
string Name;
int height;
int weight
public bool overWeight()
{
//implement something
}
}
ÀàʾÀý£º
public class TestTime
{
int hours;
int minutes;
int seconds;
public void passtime()
{
//implementation ......
ÄãÊ×ÏÈÒªÀí½âһϸÅÄ
Ò» ÀàÐÍ(Type) ¶ÔÏóÊÇʲô
±ÈÈç object x; xÊǶÔÏó£¬object¾ÍÊÇËüµÄÀàÐÍ£¬ÔÚ³ÌÐòÖÐÈçºÎÃèÊöÀàÐÍÕâ¸ö¸ÅÄîÄØ£¿
¾ÍÊÇType(System.Type)¡£Òª»ñȡij¸öÀàµÄÀàÐÍ¿ÉÒÔÓÃtypeof()²Ù×÷·û
object a;object b; DataTable t;
aType = typeof(object);Type bType = typeof(object);tType = typ ......
·þÎñÆ÷¶Ë´úÂë
¿Ø¼þ£ºbtnStart_Click£¬btnSend_Click£¬label4£¬textBox1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Threading;
using S ......