473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Learning C#

1. Put an application in sleep mode so that it consumes as little PC
resource as possible. When triggered by an event, back to normal/work mode.
After done with work, back to sleep mode again.

How can this be done in C#?

2. Is this wrong?
int *p;
*p = 5; // p is never initialized and could point to anywhere

3. How to pass p as a pointer into a function?

4. "C# is a type-safe language. Variables are declared as being of a
particular type, and each variable is constrained to hold only values of its
declared type." What's the exact meaning of "type-safe" here?

5. In 4, should it say that there are three types for variables in C#:
value, reference, and pointer?

Thanks for your help!


Oct 28 '06 #1
3 2007
"vicmann" <vi*****@hotmail.comwrote in message
news:ua****************@TK2MSFTNGP03.phx.gbl...
1. Put an application in sleep mode so that it consumes as little PC
resource as possible. When triggered by an event, back to normal/work
mode.
After done with work, back to sleep mode again.

How can this be done in C#?
In essentially the same way it would be done using the native Windows API.
The exact method depends on what "event" you mean, but the simplest example
would be to create a waitable event, use the Wait method on it, and
somewhere else use the Set method on the event to signal it and allow the
code sitting at the Wait method to continue.
2. Is this wrong?
int *p;
*p = 5; // p is never initialized and could point to anywhere
You can't even do that in C# without writing "unsafe" code. However, given
that assumption, yes...just as in C it's wrong to dereference an
uninitialized pointer, so too it is in C#.
3. How to pass p as a pointer into a function?
Again, without writing "unsafe" code, you don't. C# does however have a
"ref" keyword that allows passing things by reference.
4. "C# is a type-safe language. Variables are declared as being of a
particular type, and each variable is constrained to hold only values of
its
declared type." What's the exact meaning of "type-safe" here?
I would say "Variables are declared as being of a particular type, and each
variable is constrained to hold only values of its declared type" covers it
pretty well.
5. In 4, should it say that there are three types for variables in C#:
value, reference, and pointer?
No, not really. IMHO the "unsafe" construct is mostly a non-C# thing. That
is, it's a way to write non-C# code within C#. It reminds me a lot of using
the "__asm" keyword in C. With "real" C# code, all you have are values or
references.

Additionally, the kinds of variables don't really have anything to do with
being type-safe. That is, type-safe refers to the type checking when
variables are used. How those variables are stored doesn't relate to how
types are checked. So, no...I wouldn't expect a description of "type-safe"
to necessarily mention the kinds of variables that the language supports.

Pete
Oct 28 '06 #2
Vicman,

Is this for a palm computer or something like that (from that age as well).

On my computer are at the moment almost 500 threads runing waiting on
events, one extra will not harm that in my idea,

Cor

"vicmann" <vi*****@hotmail.comschreef in bericht
news:ua****************@TK2MSFTNGP03.phx.gbl...
1. Put an application in sleep mode so that it consumes as little PC
resource as possible. When triggered by an event, back to normal/work
mode.
After done with work, back to sleep mode again.

How can this be done in C#?

2. Is this wrong?
int *p;
*p = 5; // p is never initialized and could point to anywhere

3. How to pass p as a pointer into a function?

4. "C# is a type-safe language. Variables are declared as being of a
particular type, and each variable is constrained to hold only values of
its
declared type." What's the exact meaning of "type-safe" here?

5. In 4, should it say that there are three types for variables in C#:
value, reference, and pointer?

Thanks for your help!


Oct 28 '06 #3
Put * in C# :-). I still say look at the C# specification, there are plenty
good details in there.
http://msdn2.microsoft.com/en-us/net.../aa497266.aspx

chanmm

"vicmann" <vi*****@hotmail.comwrote in message
news:ua****************@TK2MSFTNGP03.phx.gbl...
1. Put an application in sleep mode so that it consumes as little PC
resource as possible. When triggered by an event, back to normal/work
mode.
After done with work, back to sleep mode again.

How can this be done in C#?

2. Is this wrong?
int *p;
*p = 5; // p is never initialized and could point to anywhere

3. How to pass p as a pointer into a function?

4. "C# is a type-safe language. Variables are declared as being of a
particular type, and each variable is constrained to hold only values of
its
declared type." What's the exact meaning of "type-safe" here?

5. In 4, should it say that there are three types for variables in C#:
value, reference, and pointer?

Thanks for your help!


Oct 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ron Stephens | last post by:
The newly rechristened Python Learning Foundation is a web site dedicated to the assistance of people learning the Python programming language. Features include: 1. Daily lists of new and recent...
29
by: Jhon smith | last post by:
Hi,all,I was just wondering if I am likly to have any problems trying to learn C from older books,I have some from the late 80`s,mid/late 90`s. I am using Dev-C++ on the pc windows platform,But I...
4
by: Christian Blackburn | last post by:
Hi Gang, I saw this for sale online: Microsoft Visual Basic.NET Deluxe Learning Edition Version 2003. I'm wondering is the CD that's bundled with the learning edition just a digitized version of...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
7
by: Max | last post by:
On monday I start a semester course in Python (the alternative was Java). I was looking through the course outline and noticed the following: 1) UserDict is used. This is deprecated, right? 2)...
36
by: utab | last post by:
Dear, I have experince in C( numerical projects, like engineering problems, scientific applications) I have the basic notion of C++ also, I have read Accelerated C++ until Chapter 7, however it...
2
by: bokiteam | last post by:
Hi All, Here is my idea to save learning time - Personal learning book. What we really need is somebody really familiar our learning experience, and then takes the example to teach us. Save...
78
by: arnuld | last post by:
hai all, i am standing on a "crossroad to C++". I am here in front of you as i have a problem. i will be brief. Please do not think: "arnuld is sick", i am really struggling & doing hard-work to...
0
by: LK~ICT | last post by:
Sri Lanka rural e-learning project seeks corporate support Dec 04, 2007 (LBO) - A Sri Lankan e-learning initiative for rural students is seeking corporate sector support to expand and cover 400...
16
by: John Salerno | last post by:
Just something that crosses my mind every time I delve into "Learning Python" each night. Does anyone see any value in learning Python when you don't need to for school, work, or any other reason?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.