|
Ok, I fixed that problem. So, there were two issues:
First, I had to call ReleaseHdc on the graphic object.
Secondly, the HDC parameter should have been declated as an 'out' parameter.
However, there is another problem. However, this is more related to OpenGL and probably not suitabvle for this forum.
Thanks,
Keith
|
|
|
|
|
I have been studying C# for 6 months now. Perhaps I should have but I haven't yet run into the use of var for implicit variables and - in the following example - the subsequent replacing of parentheses with braces for enclosing the parameters.
var viewModel = new StoreIndexViewModel {
NumberOfGenres = genres.Count(),
Genres = genres};
I assume there is a particular reason for this? Any help would be appreciated. Thanks.
Darrall
|
|
|
|
|
This feature of C# is known as "Object Initializers".
Read about it here or on msdn.
|
|
|
|
|
Thanks
|
|
|
|
|
You can make the code more readable (though that's subjective).
E.g
var x = new Dictionary<string, List<person>>();
instead of
Dictionary<string, List<person>> x = new Dictionary<string, List<person>>();
You can use them in LINQ queries where the result type is not obvious - the compiler will get it right. You can find out the type by hovering over the var in VS - it may not be what you think. Worth experimenting with.
This is one of those topics that cause 'religious' debates or flame wars - though that seems to have died down. Some people say 'Never' others 'Always'.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
Thanks...that makes sense
|
|
|
|
|
Hi there
Does anybody know if System.Globalization can produce a list of states/provinces for a given Country?
|
|
|
|
|
AFAIK, it cannot. One can get the list of countries from the registry entry for telephony but states, I guess no.
|
|
|
|
|
The CultureInfo class contains country and language information, but no state / province level information.
|
|
|
|
|
No it can't. That's not what it's designed to do. This type of information has to be coded/collected yourself I'm afraid (although there are purveyors of geographic database libraries out there who've done the hard work for you already).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi there
I understand I can create a list of countries in a combobox using System.Globalization.
I haven't been able to figure out how to do it.
Anybody know how?
|
|
|
|
|
public static List<string> GetCountryList()
{
List<string> cultureList = new List<string>();
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);
foreach (CultureInfo culture in cultures)
{
RegionInfo region = new RegionInfo(culture.LCID);
if (!(cultureList.Contains(region.EnglishName)))
cultureList.Add(region.EnglishName);
}
return cultureList;
} Then just add the list to the combobox
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
Wow. I had no idea .NET held a list of countries like that.
And grrrr, they had to use the French "NativeName" for Belgium. So why don't they show the US in Spanish?
In fact they do, if we look at all the cultures, including EnglishName duplicates.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
modified on Sunday, May 16, 2010 2:59 PM
|
|
|
|
|
It's nice to know it's not just me who keeps on finding new things in .NET!
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
Hi ,
I need to create a code number automatically for the name entered. If the name is already used then add a number at it's end like 1 or 2 depending upon the highest value available in the database.
something like namexx where xx is the highest number plus 1.
please help it's very urgent.
|
|
|
|
|
And what have you tried? Or since it's very urgent you expect someone to write it for you?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
i tried to put the string of the latest code in an array and parse it for int.
put the integers in a integer array. then convert them to form a string of int values and add 1 to this string converted to int.
but i couldn't split the initial string!!! what should be the split criteria?
string would be always of form
fname.lnamexxx where x could be any number 1, 99,999,9999 anything.
don't need anyone to write a code just an immediate help, if possible for split criteria of the initial string[fname.lnamexx] .
|
|
|
|
|
You don't need to parse the ints or use an array.
Assuming the names are in a datatable, something like this
int x = 1;
string name =
while(datatable.select('name = ' + name).count() != 0)
{
name = name + (x++);
}
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
oh..uh.. ..this is cool
Y did i not think this...grr
Thanks, Mark
|
|
|
|
|
OH.. this will not work if the code is deleted in between then the count and max number at end will be an issue
|
|
|
|
|
I have no idea what you are talking about.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Why don't you just have a identity column in your table. At that point, how many instances of a name (or any column value for that matter) you have is inconsequential...
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
so, add a table "known_names" to the database, two fields: name, occurence_count (do not try to reuse an existing table holding actual people!).
when adding a new name, check "known_names" for existence;
if it isn't there, add it with occurence_count=0, and use codedName=name
if it is there, increment its occurence_count, and use codedName=name+occurente_count.ToString()
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Thanks Luc,
This was the first thing that I thought as well, but I am not supposed to make changes to db model at this later stage in project.
|
|
|
|
|
then the only way left is to scan the existing coded names, find the most recent one, and "increment" it.
I once did an IncrementString() method, which basically scans a string right-to-left for digits; replaces '0' by '1', or '1' by '2', or...; up to '9' by '0' which sets a carry, meaning you have to repeat the process for the next (R-to-L) digit. This way, there is no need to explicitly extract the number. It does rely on having some other means of finding the most recent coded name though.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|