在C#中编写数据结构Stack时,只能用数组,需要指定数组大小,但有时不知道要多少大小,在C++中可以用指针解决,C#中有没有类似C++中指针的东西,
还有javascript中的Array如何实现 Stack的Push和Pop,
请大家帮帮忙,给个例子!!给个例子
还有javascript中的Array如何实现 Stack的Push和Pop,
请大家帮帮忙,给个例子!!给个例子
解决方案 »
- 因为用的是 64位的win7,每次要修改 Visual Studio“目标平台”为“x86”,还有自定义模板的问题!
- C#中怎么截获ListView中滚动条事件?
- c# winform程序运行中的强制退出的
- datagrid问题?把数据库显示出来的某行通过textbox等控件列出来
- 怎样等某个方法或是函数执行完后再执行后面的语句
- C#开发winform用到的datagrid,怎样合并单元格?
- serialport发送接求教!
- Mono.Android问题,“未处理的异常”
- 如何通过网络连接看到对方屏幕
- DrawString(string s, Font font, Brush brush, float x, float y); 坐标单位是像素吗
- 打开ie窗口的问题
- 帮我解释一下这个是什么意思??
Console.Write("the original string : ");
Console.WriteLine("{0}\r\n",s);
char[] b = new char[100];
s.CopyTo(0,b,0,20);
Console.Write("the encoded string : ");
unsafe fixed(char *p=b)NEncodeDecode(p);
for(int t=0;t<20;t++)
Console.Write(b[t]);
Console.WriteLine("\r\n");
Console.Write("the decoded string : ");
unsafe fixed(char *p=b)NEncodeDecode(p);
for(int t=0;t<20;t++)
Console.Write(b[t]);
Console.WriteLine();
}
unsafe public static void NEncodeDecode(char *s)
{
int w;
for(int y=0;y<20;y++)
{
w=(int)*(s+y);
w=w^5;
*(s+y)=(char)w;
}
}
移除数组中的最后一个元素并返回该元素。arrayObj.pop( )必选的 arrayObj 引用是一个 Array 对象。说明
如果该数组为空,那么将返回 undefined。
push 方法
将新元素添加到一个数组中,并返回数组的新长度值。arrayObj.push([item1 [item2 [. . . [itemN ]]]])参数
arrayObj必选项。一个 Array 对象。item, item2,. . . itemN可选项。该 Array 的新元素。说明
push 方法将以新元素出现的顺序添加这些元素。如果参数之一为数组,那么该数组将作为单个元素添加到数组中。如果要合并两个或多个数组中的元素,请使用 concat 方法。
这样就可以直接使用指针了。
主要project中也要勾选上编译unsafe code项-
我上面不是有给MSDN的参考了吗
在我的问题怎么用啊
能给个小例子吗