C#不安全缺乏指针? [英] Unsafe lack of pointers in C#?
本文介绍了C#不安全缺乏指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
很抱歉,如果这很明显,但我会问...
有没有一种在C#中使用指针操作的新方法?
我有一本关于C#的Deitel书,它没有提到指针这个词。也不是
不安全在索引中。
来自C / C ++世界,指针非常有意义,并且在CS上达到
的速度,指针消失了吗?
要编译,必须通知编译器该段是不安全的。 ?
多数民众赞成好吧,我可以强迫不安全/指针,但是有更新,更好的方法吗?
mtia
Sorry if this is obvious, but Ill ask...
Is there a new way of using pointer operations in C# ?
Ive got a Deitel book on C# that neither mentions the word "pointer" nor
"unsafe" in the index.
coming from a C/C++ world, pointers make perfect sense, and getting up to
speed on CS, did pointers go away?
To compile, one must inform the compiler the segment is "unsafe" ?
Thats okay, I can force unsafe/pointers, but is there a newer, better way??
mtia
推荐答案
在C ++中,指针是从
程序编程时代开始实现的一种方式。你不需要它们在C#中。使用OO结构
。
你能给我一个例子,说明你会认为指针是什么?
好东西,所以我可以用
OO方法给你一些如何做到这一点的想法?
---尼克
" Bradley1234" <所以***** @ yahoo.com>在消息中写道
news:oJKud.2305
In C++, pointers were a way of implementing things from the days of
procedural programming. You don''t need them in C#. Use OO constructs
instead.
Can you give me an example of a situation where you''d think pointers are a
good thing, so I can give you some ideas of how to do this differently using
OO methods?
--- Nick
"Bradley1234" <so*****@yahoo.com> wrote in message
news:oJKud.2305
Z %1.907@trnddc03 ...
Z%1.907@trnddc03...
对不起,如果这是显而易见的,但是生病了...
有没有一种在C#中使用指针操作的新方法?
我有一本关于C#的Deitel书,它没有提到指针这个词。也不是不安全的在指数中。
来自一个C / C ++世界,指针非常有意义,并且在CS上速度快,指针消失了吗?
为了编译,必须告知编译器该段是不安全的。这好吧,我可以强迫不安全/指针,但是有更新的,更好的
方式吗?
mtia
Sorry if this is obvious, but Ill ask...
Is there a new way of using pointer operations in C# ?
Ive got a Deitel book on C# that neither mentions the word "pointer" nor
"unsafe" in the index.
coming from a C/C++ world, pointers make perfect sense, and getting up to
speed on CS, did pointers go away?
To compile, one must inform the compiler the segment is "unsafe" ?
Thats okay, I can force unsafe/pointers, but is there a newer, better way??
mtia
嘿谢谢,这是有道理的,但它只是发生在指针上......
我有一个例子,我偶然发现了它
班级门票{
私人旅客*旅行者;
}
班级乘客{
私人清单< Ticket>门票;
}
等级座位{
私人乘客*乘客; >
}
我确定有一个流行语可以做到这一点,当我听到
它是什么时我会感到愚蠢但是当我试图把它扔进我的C#代码时,它抱怨并且
说不,你必须使用不安全。标记这种叛徒代码...
Nick Malik < NI ******* @ hotmail.nospam.com>在留言中写道
news:pQKud.484944
Hey thanks, that makes sense, but it just occured to me about pointers...
Ive got an example, where I stumbled into it
Class Ticket {
private Passenger *traveler;
}
Class Passenger {
private List<Ticket> tickets;
}
Class Seat {
private Passenger *occupant;
}
Im sure there is a buzzword for doing this, and Ill feel dumb when I hear
what it is, but when I tried to toss this into my C# code it complained and
said no, you must use "unsafe" to mark that kind of renegade code...
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:pQKud.484944
这篇关于C#不安全缺乏指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文