|
John Cardinal wrote:
Doesn't seem to be anything to read there, just advertising that it's coming in the next issue?
Did you look below the ads? There's plenty more after the ads, and more after that below some more ads.
John Cardinal wrote:
I've never heard of D either
As they said, it's written by one person, and marketed by a small company, so it's not too well-known.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
jdunlap wrote:
John Cardinal wrote:
I've never heard of D either
As they said, it's written by one person, and marketed by a small company, so it's not too well-known.
That and theres what I think 2000 languages out there. I think thats what my java instructor told me. Boy that was grueling. All I ever heard was how much worse c++ is compared to Java. That darn SUN
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
John Cardinal wrote:
I've never heard of D either, maybe it's a typo or they haven't finalized the article yet?
Isn't that the new language that Microsoft is putting out? They are supposed to have a visual version like VC, of that also, right? I do not know how popular Microsoft's VD 1.0 will be, I am sure people will want to get rid of it quickly...
(This was a late night attempt and humor )
Rocky Moore <><
|
|
|
|
|
D is a programming language that was designed as a successor to C/C++, but to include such things as garbage collection, design by contract, lightweight objects, RAII, compiles to native code, etc, etc. Think of a mix between C# and C++, leaning towards C++. It has some very interesting concepts.
It's designed and implemented by Walter Bright, a C/C++ compiler implementor from way back (I remember his company Zortech, later Zorland).
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
|
Conclusions: C++ has better performance in some areas, and C# has better performance in others, and there are a few places that Java outperforms C# and/or C++, but on the whole C# has better performance than Java. C++ starts up faster than C#, and C# has a number of new, modern language features.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hi
I wanna draw many same objects & define when user click on
one from objects. What should i used Graphics or GraphicsPath
Best regards.
|
|
|
|
|
is it possible to loop through each row of a dataset table, and populate the new column based on another column in the same row?
i have a Contacts class, and a Message Center class. Each get their information from completely different databases, and reference only by the ContactID. ( the messages table in its database only has a contactid field .. not a contact name field )
The constructor of the Contact class takes the ContactID as the argument.
I want to create a dataset of the last 50 messages and have the Contact Name in the same data set.
for example:
<br />
. . . . . . . .<br />
string sql = "SELECT ContactID,Message from Messages ORDER BY MessageID DESC LIMIT 50";<br />
SqlDataAdapter da = new SqlDataAdapter(sql,con);<br />
ds = new DataSet();<br />
da.Fill(ds,"Messages");<br />
<br />
ds.Tables["Messages"].Columns.Add("ContactName");<br />
Now how would I iterate through each row of the Messages.ContactID table, and populate the Messages.ContactName field of the same row ?
I hope I made sense =/ .. Thanks for reading this.
|
|
|
|
|
after messing around with the beautiful intellisense of vs, i think this might work:
for(int i=0; i ds.Tables["Issues"].Rows.Count ; i++)
{
Contacts.Contact Contact = new Contacts.Contact(ds.Tables["Messages"].Rows[i]["ContactID"]);
ds.Tables["Messages"].Rows[i]["ContactName"] = Contact.FirstName + " " + Contact.LastName;
}
|
|
|
|
|
In sql I would say
SELECT MES.ContactID, CON.COntactName, MES.Message FROM MessageDatabase..Messages AS MES
INNER JOIN ContactDatabase..Contacts AS CON ON MES.ContactID = CON.ID
ORDER BY MES.MessageID DESC LIMIT 50
that would combine them
or in code
dsTables["Messages"].Columns.Add("ContactName");
foreach( DataRow row in dsTables["Messages"] )
row["ContactName"] = Contact.FullName;
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Foreach loop will be work in this case, but in some cases as adding/deleting rows or modifing primary keys or some computations (resetting expressions to null - it's .net error) will not.
Hi,
AW
|
|
|
|
|
explain further on that. Dont see how foreach won't work. Its the same as using a counter just cleaner code. You can always test for null or the famous DBNull value
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
It's not a joke; see help (.Net Framework, foreach, syntax):
The foreach statement is used to iterate through the collection to get the desired information, but should not be used to change the contents of the collection to avoid unpredictable side effects
I spent some nights with fighting with error at computed fields/expressions ...
Hi,
AW
|
|
|
|
|
hey can you post a link to that?
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Yes and no actually
The foreach statement repeats a group of embedded statements for each element in an array or an object collection. The foreach statement is used to iterate through the collection to get the desired information, but should not be used to change the contents of the collection to avoid unpredictable side effects. The statement takes the following form:
This doesnt mean you cant change the data in the elements of the collections just the contents of a collection.
Like so, if you add, delete, or sort the collection while inside an enumerator it will have un expected results for the simple fact that is an Enumerator and just grabs one time data. Much like modifying a pointer while iterating.
You can change the data inside the elements without it affecting them.
I have more than 20 classes linked to datagrids and use foreach to iterate through them and have not witnessed any unpredicted results yet. And besides all doc code shows ms using that especially in implementing collections.
Could use post a code example or detailed situation so I could try it and determine the root problem.
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
It's clear. The error is only with computed fields, I send it some time ago to C#corner forum (it's now unusable). It's solved now. The reason is:
1. I created a table with about 400 fields dynamically.
2. I assigned Expression based on another fields to one of them:
dtBufor.Columns["aggr"].Expression="...";
3. I assigned null (or zer-length string) to this expression
4. After it getting from any table field was possible, but setting - sometimes impossible. Using dtBufor.Rows[rowno]["fieldname"] generated an immediate NullObjectReference error and dtBufor.Rows[rowno].ItemArray[fieldno] updated nothing without error
5. After setting Expression="0" it works (workaround).
6. See http://www.codeproject.com/script/comments/forums.asp?forumid=1649&mode=all&userid=56906&select=407524&df=100&app=50&fr=8305#xx407524xx
Hi,
AW
|
|
|
|
|
Hi,
A terrible mistake I formatted the wrong drive and along with it my C# project.. All I have is the release executable.. Is there any way I can re-engineer this back to my code.. I mean if it's in byte code...
Please Please help!!
|
|
|
|
|
Yes, you can, using Anakrino[^].
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hi.
I am trying to figure out how to find the appropriate icon for a specific file type (e.g. txt files), with out actually having a file to go by? I have tried the SHGetFileInfo, but that dont know when I dont have a file to get the information from. Can anyone help me?
Nightcrawler7514
Resistance is futile - Data (ST:First Contact)
|
|
|
|
|
Actually, this is about the only wait to do it if you want the information for a file that doesn't exist (without doing all the registry and icon handling yourself). It's easy to make work, though - I've used this alot. Below is an example:
public class FileInfo
{
private int const FILE_ATTRIBUTE_NORMAL = 0x80;
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
private static extern IntPtr SHGetFileInfo(
string path,
int fileAttributes,
[MarshalAs(UnmanagedType.Struct), Out]out SHFileInfo info,
int fileInfoSize,
[MarshalAs(UnmanagedType.U4)]SHGFI flags);
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
private struct SHFileInfo
{
public IntPtr IconHandle;
public int IconIndex;
public int Attributes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]
public string DisplayName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)]
public string FileType;
}
[Flags]
private enum SHGFI
{
LargeIcon = 0x0,
SmallIcon = 0x1,
OpenIcon = 0x2,
ShallIconSize = 0x4,
PIDL = 0x08,
UseFileAttribute = 0x10,
AddOverlays = 0x20,
OverlayIndex = 0x40,
Icon = 0x0100,
DisplayName = 0x200,
TypeName = 0x400,
Attributes = 0x800,
IconLocation = 0x1000,
EXEType = 0x2000,
SysIconIndex = 0x4000,
LinkOverlay = 0x8000,
Selected = 0x10000,
AttrSpecified = 0x20000
}
public static bool GetFileInformation(string filename,
out string fileType, out Image fileImage)
{
SHFileInfo info = new SHFileInfo();
IntPtr retVal = SHGetFileInfo(filename, FILE_ATTRIBUTE_NORMAL,
out info, Marshal.SizeOf(typeof(SHFileInfo),
SHGFI.AddOverlays | SHGFI.DisplayName | SHGFI.Icon | SHGFI.SmallIcon
| SHGFI.TypeName | SHGFI.UseFileAttributes);
if (retVal != IntPtr.Zero)
{
fileType = info.FileType;
fileImage = Bitmap.FromHicon(info.IconHandle);
return true;
}
else return false;
}
} I just threw that together quick, so don't just copy and paste. You won't learn anything that way anyway. You had the right idea, but you must've been prototyping something wrong or forgetting about the marshaling stuff, whichis necessary is several cases in this example (such as pass-by-value strings).
-----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-----
|
|
|
|
|
MAN.. I could kiss you. IT WORKED. I was actually on to it, but I can see where I made the mistake now. THANKS ALOT. You are a life saver.
Nightcrawler7514
Resistance is futile - Data (ST:First Contact)
|
|
|
|
|
Can anyone tell me how to trap the enter key on a windows form application? I want to call a function when the user hits enter. Also, can anyone tell me where I can find the ascii values for the keyboard keys.
Thanks
|
|
|
|
|
So many questions - so little time!
First, you can trap the Enter key with the keyboard events. You can capture the key with the KeyDown or KeyUp events on the Form , while setting Form.KeyPreview to true if you want it to receive notification of keyboard events from all controls (it's the parent HWND in the chain to be notified of messages if controls let them).
KeyUp would probably be better because it gives a (knowledgeable) user the chance to cancel the event with the Esc key.
Each of these events has a KeyEventArgs.KeyCode that corresponds to a Keys enumeration. You most likely shouldn't hardcode the ASCII key code because those can change with different codepages. .NET (and the Windows subsystem that drives it) takes a lot of this into account. Most likely the key code won't change for the Enter key, but why take the chance when it's so easy to just use the enumeration?
If you want the ASCII keys anyway (bad bad bad!) or for some other reason, just type "ASCII" into the help index - you know, the think you should've checked first. You'll see "ASCII character sets" (and many other links) that have the ASCII charts of 0-127 and 128-256.
-----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-----
|
|
|
|
|
Heath,
Thanks that was excatly what I was looking for!
|
|
|
|
|
Hi, just reading up on async delegates samples from MSDN.Reference:
".NET Framework Developer's Guide Asynchronous Delegates Programming Sample"
Some questions here, you guru can definitely explain this:
QUESTION 1:
Object state = new Object(); //What do we need this object for?
// Asynchronously invoke the Factorize method on pf.
IAsyncResult ar = fd.BeginInvoke(
factorizableNum,
ref temp,
ref temp,
cb, //Async callback delegate: invoke fc.FactorizedResults when pf.Factorize completes.
state); //What do we need this object for?
QUESTION 2:
I was expecting input parameter to WaitOne would be a Mutex or AutoResetEvent... etc:
AutoResetEvent e;
WaitHandle.WaitOne(e);
But instead, from our MSDN sample:
IAsyncResult ar = fd.BeginInvoke(
factorizableNum,
ref temp,
ref temp,
null,
null);
ar.AsyncWaitHandle.WaitOne(10000, false);
(2-a) I guess .NET framework signal a waitable handle encapsulated by IAsyncResult ar.. signaling it when fd delegate(s) completes. Is my understanding correct?
(2-b) What if there're more than one handler? Should I WaitAll instead?
ar.AsyncWaitHandle.WaitAll(10000, false);
That's it. Thanks.
norm
|
|
|
|
|