|
eggie5 wrote:
Oh, my god.... oh my god. it's so simple...
Simple, yes....but I'll admit it recently had me stumped for a while!
|
|
|
|
|
How do i use them and what i can use them for?
Thanks
Da Intern
|
|
|
|
|
Q: What is API?
A: Application Protocol Interface, it's a system of functions/methods usually provided by a 3rd party used in your code.
Q: What are they for?
A: Depends, too general of a question.
|
|
|
|
|
Daniel M. Edwards wrote:
Protocol
Programming
|
|
|
|
|
I wonder how long it would take to become a Senior Software Engineer asking this broad, general questions and hoping for an answer in a forum like this.
I think that if you are at the level where you don't even know what API stands for, buying entry level books would be so much helpful on the road to become a professional programmer.
Regards,
Carlos H. Perez.
|
|
|
|
|
Very good advice, and very nicely put, too.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
how do i add headers and add information into the headers.
I added the headers in the design view by using the properties menu but how do i add the header it is not displaying in the listview and bind information to it?
I know its a begineer question but i need some help please thanks!! ;)
Da Intern
|
|
|
|
|
Set the ListView.View property to View.Details , or simply Details in the designer.
To add information to columns, read the documentation for the ListViewItem class, which also includes some samples.
As far as data-binding support like in the DataGrid class, there is none. You have to add this yourself using the DataBindings property or manually (which really isn't data binding).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi, I just have a quick question on compiling. Why is it, that code that is the same length in c++ and c#, compile a lot quicker in c#?
I noticed how much quicker these things are. My question is, how do c++ programmers not commit suicide while waiting for a program to compile?
|
|
|
|
|
toticow wrote:
Why is it, that code that is the same length in c++ and c#, compile a lot quicker in c#?
Because it doesn't compile, it gets turned into IL that gets compiled by the VM the first time it is run.
toticow wrote:
My question is, how do c++ programmers not commit suicide while waiting for a program to compile?
Because our programs are faster at the end. Also, by being intelligent about how things are organised, compilation times can be made faster in C++.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Christian Graus wrote:
Because it doesn't compile
What does it do exactly then?
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
leppie wrote:
What does it do exactly then?
It does what I said it does. You can argue semantics on my original post, but it does NOT get compiled into anything your computer can use, it gets compiled into IL, an intermediate step before final compilation into actual, runnable code happens at run time.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
There are a number of reasons why C# compiles faster than C++. Here are the ones I thought of - there are likely more.
1) No preprocessor. In C++, you either need a separate preprocessor step or a fairly complex on-the-fly preprocessor (I don't remember offhand what VC++ does). In C#, you can easily do everything on the fly.
2) "All at once" compile model. In C#, all the compilands are compiled at once, and in C++, one file at a time, plus link time at the end.
3) Much easier metadata model. The #include model of C++ doesn't scale particularly well, and it requires reading the include files in textual format (including the preprocessor step) for every compilation. Compilers can get around this with "precompiled headers", which helps get rid of some of the overhead, but at the expense of more complexity when the set of includes changes. It also only applies to system headers, not ones from the current project. C# gets the ability to read in metadata in a binary format and more importantly, on a per-assembly basis. This is roughly the difference between looking for data in a database and looking through a text file to find the data.
4) Smaller set of libraries to consider. The Win32 Platform SDK is a huge beast, and typically has gotten bigger with each release. On the C++ team, it was not uncommon for us to work hard to get 10-20% increase in compile speed, only to see all of that eaten up by the increase in size of the windows headers.
4) Very limited compiler optimization. The C++ optimizer on release builds will normally take more time on a per-file basis than the parsing phase, though I will point out that even if you build a debug, non-optized build, C# is still quite a bit faster.
Eric Gunnerson
Current C# Compiler Program Manager
Past Visual C# Compiler QA Lead
Past Visual C++ Compiler QA Lead
|
|
|
|
|
Am I the only person who's noticed that enumerated values in C# suck? They hold integer values yet they can't be used as integers without casting.
Like in C++, I'd like to use an enumerated value to retrieve an array element by index, or as a bitmask value which may be ORed or ANDed. But no, I have to add the yucky (int) cast every time. What a load of crap!
Anyone else think they should have made the compiler work more like in C++ with regards to enumerated values? Why didn't they? Is this "feature" also prevalent in VB.NET?
Thanks,
Alvaro
Can I ask you a question?
|
|
|
|
|
First, you *can* do bitwise ops on Enum values without casting, but you might want to mark the enum with the FlagsAttribute if you do so (which VS.NET, at least, uses in some cases).
Since enums can be defined as various at various int sizes and signed or unsigned, that implicit cast would have to follow the enum's int type or risk a lossy cast (can't cast to Int32 from Int64 without a loss of data similar with unit to int). I prefer the type safety and un-ambiguity, and if you need it, the int value is there.
R.
|
|
|
|
|
Richard Lowe wrote:
First, you *can* do bitwise ops on Enum values without casting, but you might want to mark the enum with the FlagsAttribute if you do so (which VS.NET, at least, uses in some cases).
Um, no. It doesn't work. Tell me if this compiles for you:
[Flags]
enum e { e0, e1, e2 };
void foo()
{
int i = e.e1 | e.e2;
bool b = (i & e.e1) != 0;
}
Richard Lowe wrote:
Since enums can be defined as various at various int sizes and signed or unsigned, that implicit cast would have to follow the enum's int type or risk a lossy cast (can't cast to Int32 from Int64 without a loss of data similar with unit to int). I prefer the type safety and un-ambiguity, and if you need it, the int value is there.
Hmmm, it may be that I've gotten used to employing enums for more than what they're really designed for. I guess I'll have to revert back to the Java way: use const ints.
Regards,
Alvaro
Can I ask you a question?
|
|
|
|
|
Alvaro Mendez wrote:
[Flags]enum e { e0, e1, e2 }; void foo(){ int i = e.e1 | e.e2; bool b = (i & e.e1) != 0;}
No, but this does:
e = e.e1 | e.e2;
bool b = (e & e.e1) != 0;
I do it all the time.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Yeah, that's nice.
Unfortunately, this forces you to predefine all your bit values in the same enum. If you then create a derived class with an extended set of bits, inside its own enum, you can't AND or OR those to the base class's. You follow me? In other words, for class hierarchies this doesn't work. If enum types could be derived, it'd be another story, but...
Regards,
Alvaro
Can I ask you a question?
|
|
|
|
|
C# enums are not primarily used for giving integer constants names. For that purpose you use integer constants. Enums are a type of their own. Thats why they have to be casted if you want to use them as integers. That, together with not treating 0/1 as boolean values, are just ways to improve the language and enforce type safety, that makes us programmers write safer code.
Your examples of bitwise operations dont work because you try to implicitly convert to Int32.
|
|
|
|
|
A bitwise operation on one Enum to another Enum yields *an Enum* - not an int. They keep their type safety. So assign the result to an Enum and it works.
|
|
|
|
|
I am handling the MouseHover event for my toolbar. I would like to find out which button in the toolbar the mouse cursor is hovering over. How do I determine this?
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
With the BCL ToolBar class, you have to get the mouse coordinates (this is easy), convert to client coordinates in relation to the toolbar (call PoingToClient on the toolbar instance) and enumerate your toolbar buttons to find out over which the point lies.
For most applications, I recommend you go with a decent 3rd-party toolbar. They have a lot more functionality.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
The Scenario
I've created a custom control that has a public property that is of an enumerated value type. I have created an accessor method to get/set that property and have it 'binded'. Finally, in the constructor for the control, I set that property to a default value, referencing the full namespace of the enum value type to ensure no conflicts with other controls would exist (see sample code below):
<br />
namespace MyControls {<br />
<br />
public class MyCustomControl : System.Windows.Forms.Label <br />
{<br />
public enum MyLabelType { High, Low, Special, Hidden };<br />
<br />
private MyLabelType myLabelType;<br />
<br />
public MyCustomControl <br />
{<br />
myLabelType = MyControls.MyCustomControl.MyLabelType.Special;<br />
}<br />
<br />
...<br />
<br />
[Bindable(true), Category("Custom Properties"),<br />
Description("My Custom Control ...")]<br />
public MyControls.MyCustomControl.MyLabelType LabelType<br />
{<br />
get ... <br />
set ...<br />
} <br />
<br />
...<br />
<br />
}<br />
}<br />
The Problem
I drop the custom control onto a form and set my properties without a hitch. I add a using clause to my code for that namespace and do a build. I get no errors, I can run the application without issues ... Etc. However, if I close the solution/project, and open it back up, then open that form back up in design mode, I get errors on that enumerated property that indicates "The variable 'MyLabelType' is either undeclared or was never assigned".
When I attempt to set a variable to this value type my code, the intellisense doesn't "find" the enum value type. (Example):
MyControls.MyCustomControl.MyLabelType is not found ...
Yet if I open custom control solution in studio, rebuild it, and then go BACK to my solution that uses the custom control, studio can now "see" the enumerated data type ...
I have tried to set the "DefaultValue" on the property accessor for this type, but to no avail. It does not seem to affect the outcome.
Any suggestions or answers as to what I am doing wrong, or to why this is happening? I'm guessing the solution is something simple that I am just overlooking.
TIA
D.
|
|
|
|
|
I'm trying to pass a reference of Form1 to Form2 so I can change things on Form1 from Form2.
Here is my logic:
Form1
private void btnShow_Click(object sender, System.EventArgs e)
{
FormTwo = new Form2(ref this);
FormTwo.Show();
}
Form2:
public Form2(ref Form1 PassingForm)
{
InitializeComponent();
FormOne = PassingForm;
}
error CS1605: Cannot pass '<this>' as a ref or out argument because it is read-only
i can read the error, .. but what would the proper logic be here?
|
|
|
|
|
You don't need 'ref', because a Form1 is already a reference type. The error occurs because you're trying to pass a reference to 'this', which cannot be changed.
Personally I find reference languages confusing, because of the nature of aliasing and that there are no clues in the syntax indicating whether you're dealing with a value (which uses a shallow copy) or a reference (which merely copies the reference).
|
|
|
|
|