|
1. If there any exceptions in the lines between creation of Bitmap, Graphics objects and their disposal, you'll leak memory. The right way to write the code is to either use try/finally or use the using statement. Like
using (Bitmap imgOutput = new Bitmap(...))
{
}
or
Bitmap imgOutput = null;
try
{
imgOutput = new Bitmap(...)
}
finally
{
if (imgOutput != null) imgOutput.Dispose();
}
2. I can't see any memory leaks if there are no exceptions. However, I'm suspicious about the Source bitmap. Who allocates memory for that bitmap? If you create bitmap objects by supplying an IntPtr, you are responsible for cleaning up the memory pointed to by IntPtr, the bitmap object's Dispose only clears off it's internal memory.
I'd suggest using a memory profiler like CLRProfiler[^] to find out where the leak is. All you have to do is run the application under the profiler and it will show you a neat diagram with all the managed objects in the heap and their creation call stacks.
|
|
|
|
|
1. there are no exceptions in this program
2.
>"However, I'm suspicious about the Source bitmap. Who allocates memory for that bitmap?"
All ok. If you noticed, the last line in this method is a simlpe driver for testing: so, when i comment all lines except the last one, the method becomes wery simple to test. In such case no leak appears.
> "If you create bitmap objects by supplying an IntPtr, you are responsible for cleaning up the memory pointed to by IntPtr, the bitmap object's Dispose only clears off it's internal memory."
Hm.. I understand that i have to do something with IntPtr (and i decide to renew it). But how can i "cleaning up the memory pointed to by IntPtr"?
About profiler. At my computer it run wery slow and there are a lot of different data. I can't understand anything now
|
|
|
|
|
lak-b wrote: Hm.. I understand that i have to do something with IntPtr (and i decide to renew it). But how can i "cleaning up the memory pointed to by IntPtr"?
Simply calling new IntPtr() doesn't clear off the memory, you need to find out how memory was allocated for the pointer (like using Marshal.AllocHGlobal) and use the corresponding free function to free up the memory.
lak-b wrote: About profiler. At my computer it run wery slow and there are a lot of different data.
Yes, your app will run slower in the profiler. The word document that comes with the profiler can help you figure out what the data means. The first diagram that comes up shows the objects allocated so far and the method stack which led to their allocation. However, it only shows managed objects, so if you're leaking unmanaged memory (for e.g. by calling AllocXXX but not calling FreeXXX), CLR Profiler won't help.
To quickly find out whether you're leaking managed or unmanaged memory, fire up perfmon (Type perfmon.msc at the command prompt), right click on the graph, click Add Counters, select ".NET CLR Memory" from the Performance Object combobox, select your process in the list box in the right and select "#Bytes in all Heaps" in the listbox on the right. Hit Add, Close. Repeat the operation that leads to the memory leak and check if the "#Bytes in all Heaps" counter's value keeps increasing proportionately. If it does, you have a managed memory leak, otherwise, you are leaking unmanaged memory.
|
|
|
|
|
Hi,
I am building a class library for a reporting application. The following is the scenario and would like to know what type of pattern is appropriate for this kind of implementation:
To give a little bit of context, we are trying to determine the current status of various metric of a project. The status would be red, green or yellow based on the output value in an Metric. You can think of metrics are like Performance%, Security%, number of Bugs etc.
I have a class called as MetricReport which would produce one output number. This number would be compared to various targets to track the progress of the metric in question to produce status colors like Red, Yellow or Green.
Some scenarios of comparisons are:
1. MetricReport output number would be compared to Target values. The target values would be two numbers. Let’s assume that the target values for Performance Percentage are 90% and 70%. So, if the MetricReport value number is 80% then the metric is considered to be on Yellow status. If it is 95%, then considered as green. If it less 70% then it is considered as Red.
2. Baseline Scenario – Here MetricReport output number is compared to another report - BaseLineReport. Threshold values(which again is 2 numbers) are then applied on the BaseLineReport. So for example if Baseline Report produces a value of 70% as the Perf %, then threshold values of +5%(upper threshold) and 10%(lower threshold) are applied. Now, if our MetricReport produces a value greater than 70% + 5%(BaselineReport output plus the upperThreshold) then the metric turns green. If the MetricReport output value is lesser than 70% - 10%(BaselineReport output minus the lowerThreshold), then the metric turns red. Any values in between 75% and 60% is yellow.
3. Trend scenario – Here MetricReport output number is compared to a Trend. A Trend is something where you setup the start value, end value, start date and end date. The slope of the line is determined based on the start value and end value and the number of days between start date and end date. Threshold values(which again is 2 numbers) are then applied on the Trend. So for example if Trend produces a value of 70% as the Perf % (for a particular day), then threshold values of +5%(upper threshold) and 10%(lower threshold) are applied. Now, if our MetricReport produces a value greater than 70% + 5%(Trend output plus the upperThreshold) then the metric turns green. If the MetricReport output value is lesser than 70% - 10%(Trend output minus the lowerThreshold), then the metric turns red. Any values in between 75% and 60% is yellow.
So, you can summarize the above scenarios like:
MetricOutputValue + TargetValues – determines the color of the Metric
MetricOutputValue + BaselineReport + Threshold – determines the color of the Metric
MetricOutputValue + Trend + Threshold – determines the color of the Metric
The question is how to put this information into classes. I want this to be flexible so that in the future I would be expand it into new scenarios.
Currently I have the following classes:
1. MetricReport – produces one output number as a result
2. SimpleMetric – (supports scenario 1 above) This class takes a MetricReport as a child in the class, accepts TargetValues and does the calculations to determine the color.
3. BaselineMetric - (supports scenario 2 above) This class takes a MetricReport class and BaseLineReport class as children, accepts ThresholdValues and does the calculations to determine the color.
4. TrendMetric - (supports scenario 3 above) This class takes a MetricReport as a child in the class, accepts Trend information and ThresholdValues. With this data it does the calculations to determine the color.
I am thinking that this design is not that expandable, since Threshold is like a wrapper which is applied to classes and needs to be extracted to a separate class. Initially Decorator pattern looked like may suit this scenario. But all the examples I looked up for this pattern does not seem to suit this scenario perfectly. I thought of a scenario where I decorate a MetricReport with BaseLineReport and then decorate again on top with Threshold to support Scenario 2 above. But since the Threshold would need that the component be decorated with a BaseLineReport/Trend before it can be decorated with Threshold. I don’t know how to enforce this with the decorator.
Can you suggest what would be appropriate design for this situation..
Thanks a lot .
|
|
|
|
|
jubilanttiger wrote: I thought of a scenario where I decorate a MetricReport with BaseLineReport and then decorate again on top with Threshold to support Scenario 2 above. But since the Threshold would need that the component be decorated with a BaseLineReport/Trend before it can be decorated with Threshold. I don’t know how to enforce this with the decorator.
I'm not sure I understand to any depth the domain you've described, but my impression is that you have classes that wrap other classes and provide additional information/functionality. It's kind of like those Russian dolls where when you open one to find out what's inside, you find a smaller doll.
So say we have classes A, B, and C. 'A' is just a run of the mill class that represents something. Class 'B' takes an 'A' object in its constructor and "decorates" it with additional functionality. Class 'C' does the same using 'B'. Is this something along the lines of what you're trying to do?
It's the last line, "I don't know how to enforce this with the decorator" that has me a little confused. As long as the type of class you're decorating is specified in the constructor of the decorator class, the decorator/decoratee relationship is enforced.
It may be helpful if you can describe your problem in more abstract terms. With a problem like this, it's easy for someone not familiar with the domain to get confused by the details.
|
|
|
|
|
hi all,
i tried to abort thread but when i make
myThread.Abort();
it give me an exception of aborting thread so what can i do to avoid this exception
another thing is that Suspend Method is obsolete(help said)
what is the alternative
third and last:
when i declare thread as member data in class it refuses to identify the name of the method i used to initialize
like:
Thread packetsMovingThread = new Thread(new ThreadStart(threadProcedure));
private threadProcedure()
{
my method
}
thanx
Generator
|
|
|
|
|
HexaDeveloper wrote: i tried to abort thread but when i make
myThread.Abort();
it give me an exception of aborting thread so what can i do to avoid this exception
Allow the thread to end naturally. Typically, a thread method has a loop that it runs until it completes its task.
private void ThreadMethod
{
while(notDone)
{
}
}
HexaDeveloper wrote: another thing is that Suspend Method is obsolete(help said)
what is the alternative
Hmm, well you could use locking to pause a thread:
private void ThreadMethod
{
lock(lockObject)
{
Monitor.Wait(lockObject);
}
while(!done)
{
}
}
And at the point in which you create the thread:
Thread myThread = new Thread(ThreadMethod);
myThread.Start();
lock(lockObject)
{
Monitor.Pulse(lockObject);
}
This will create a thread and start it. The thread runs until it reaches the Monitor.Wait(lockObject) statement. At that point, it's up to you to wake up the thread and let it do its thing. This is done above with the Monitor.Pulse(lockObject) statement.
Now, often times you want a thread to wait periodically instead of just when it's started up. So we can put a Wait inside the loop:
private void ThreadMethod
{
lock(lockObject)
{
while(!done)
{
Monitor.Wait(lockObject);
if(done)
{
break;
}
}
}
}
Then it's up to your application to periodically wake up the thread to do its work. Hope this helps.
HexaDeveloper wrote: third and last:
when i declare thread as member data in class it refuses to identify the name of the method i used to initialize
like:
This question I don't understand. Can you elaborate?
|
|
|
|
|
hi,
i mean when i write
Thread myThread = new Thread(ThreadMethod);
it said
[Error 1 A field initializer cannot reference the nonstatic field, method, or property 'Interface.mainScreen.threadProcedure()' C:\Documents and Settings\Administrator\Desktop\Well Formed Interface_thread\Interface\mainScreen.cs 38 49 Interface
]
and i am actually want to know the reason that when i used abort it makes exception
and i want to ask if i can make the lockobject my thread name
thanx
-- modified at 12:02 Wednesday 11th April, 2007
Generator
-- modified at 14:19 Wednesday 11th April, 2007
|
|
|
|
|
How would I make a value from database reference the string value in the combobox. For example, 2 is the value from the database and the display value is "Las Value" How would do it? I can use select statement to get the string value but wondering if there is any other way.
|
|
|
|
|
Why don't you have a lookup list somewhere - in the database for example.
|
|
|
|
|
Hello All,
Currently I have developed an application using VC++ 6.0. Latter when "Developer Environment 2003" came I migrated to VC++.NET. But my code is fully like VC++ 6.0 code (I have not used .NET fully in my project)
I am planning to move this project to either C# or VC++. NET fully. I want your suggetion which will be better. Application uses MFC for GUI, Database, File operations, COM for communication between different modules and multithreading extensively. Suggest me which is better for such type of project C# or VC++.NET!!!
I want to have better GUI, easy DB Support, File oprations, easier COM communication and mainly Mulithreading and IPC should be easy. Memory leaks it is automatically taken care I can be more lazy .
Suggest me better option between 2.
Thanks
Ravi
|
|
|
|
|
On the areas you want to be easier to deal with C# is the obvious winner. However, you have to balance that with the migration cost.
|
|
|
|
|
Here is a straight forward question: Is it better to declare refrence values locally. For instance you have an object with two data types int. In your using object you need to use those continuously, do you use them from their source or do you create local primative types to hold their values.
Just curious which is the better practice and performance.
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
I have no idea what you mean by that. Could you provide code examples of what you mean?
|
|
|
|
|
This is more theoretical than anything else and I have heard variations.
Generally you have a class:
public class employee<br />
{<br />
string employeeName;<br />
int empID;<br />
<br />
(Some other methods)<br />
<br />
}
In the using class, say company you could just reference the employeeName through its class such as employee.employeeName. But if you need to continuously reference that name do you want to do this or do you want to do:
<br />
public class company<br />
{<br />
string employeeName = employee.employeeName;<br />
}<br />
Then use the local, or is it better to alway just call the employee.employeeName.
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
Oh, I see. Well, if it is something as simple as accessing a field then I don't think there is much advantage in saving it locally. Also, you really ought not to be accessing the fields of a class directly from outside the class in which it is declared.
If you are accessing a property then there possibily is an advantage is saving it locally. The property could, for example, have to do a look up each time it is called - That takes time, so it would be better if that didn't have to happen.
Often, I'll save the value locally for improved readability more than any other reason. All those excessively long lines can be difficult to debug, especially if you are stepping through code and you keep stepping in and out of properties in one line of code.
|
|
|
|
|
Thanks,
It really was a stupid question, one of those where for no reason you just wanna get an idea since you have always done something in a way but never wondered if it really made any difference. Kinda like stings and string builders. Truly makes a difference.
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
Hi,
How to invoke web service methods in C#.Net?
Thanks in advance
|
|
|
|
|
The question is a bit short to really understand your problem. But I will try to guess here.
The most basic operation to be able to use a webservice in your application is to right-click on the project and choose Add Web Reference. There you browse to the webservice, give it a good name and select OK.
After that it's just simply a matter of doing something like this:
ServiceClass service = new ServiceClass();<br />
object someResult = service.SomeMethod(someParameter);
The service class is strongly typed, so you shouldn't have much trouble finding out how to call the service and what to pass and what you get in return.
Hope this helps
WM.
What about weapons of mass-construction?
"What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson
|
|
|
|
|
I have a complex query.. with differnent tables...
n i want it to be displayed in my report viewer on my c# winform...
I want all formating and other coding to be done without using any GUI wizards for the report viewer.. Everything hardcored... and i want to have total control on the report viewer to display each an every item precisely where i want...
Plz... Help me I'm undergoing my academic project
and in badly need of it
me
vin'S
ww.vinsblogs.blogspot.com
VINAYAK J BADDI
www.vinsblogs.blogspot.com
|
|
|
|
|
All dear friends of this forum i'm asking you help.
I have to create simple poker game in console application.
I created already but this via functions. I need to create with structs this game. Plz help me. I can't succeed almost 2 weeks....
I understand that is hard question but this code is ready and it works
just how to create this in structs and not in functions
And how can i upload file to this forum.
arr[j + 1])<br />
{<br />
temp = arr[j];<br />
arr[j] = arr[j + 1];<br />
arr[j + 1] = temp;<br />
} <br />
}<br />
<br />
static void InitializeHand(int[] hand)<br />
{<br />
Random rnd = new Random();<br />
hand[0] = rnd.Next(0, 52);<br />
for (int i = 1; i < hand.Length; i++)<br />
{<br />
hand[i] = rnd.Next(0, 52);<br />
for (int j = i - 1; j >= 0; j--)<br />
if (hand[i] == hand[j])<br />
{<br />
i--;<br />
break;<br />
}<br />
} <br />
} <br />
<br />
static void PrintHand(int[] hand)<br />
{<br />
char sign = ' ';<br />
string card = "";<br />
int val;<br />
Console.WriteLine("Your hand:"); <br />
<br />
for (int i = 0; i < hand.Length; i++)<br />
{<br />
val = hand[i] / 13;<br />
switch (val)<br />
{<br />
case 0:<br />
sign = '♠';<br />
break;<br />
case 1:<br />
sign = '♣';<br />
break;<br />
case 2:<br />
sign = '♥';<br />
break;<br />
case 3:<br />
sign = '♦';<br />
break;<br />
}<br />
<br />
val = hand[i] % 13;<br />
switch (val)<br />
{<br />
case 0:<br />
card = "A";<br />
break;<br />
case 1:<br />
case 2:<br />
case 3:<br />
case 4:<br />
case 5:<br />
case 6:<br />
case 7:<br />
case 8:<br />
case 9:<br />
card = (val + 1).ToString();<br />
break;<br />
case 10:<br />
card = "J";<br />
break;<br />
case 11:<br />
card = "Q";<br />
break;<br />
case 12:<br />
card = "K";<br />
break;<br />
}<br />
<br />
Console.WriteLine("{0}.{1,3} {2}", i + 1, card, sign);<br />
}<br />
}<br />
<br />
static int[] GetPics(int[] hand)<br />
{<br />
int[] arr = new int[hand.Length];<br />
for (int i = 0; i < arr.Length; i++)<br />
arr[i] = hand[i] % 13;<br />
return arr;<br />
}<br />
<br />
static bool Flush(int[] hand)<br />
{<br />
if (hand[0] / 13 == hand[1]/13 && hand[1]/13 == hand[2] / 13 && hand[2] / 13 == hand[3] / 13 && hand [3] / 13 == hand[4] / 13)<br />
return true;<br />
else<br />
return false;<br />
}<br />
<br />
static bool Straight(int[] hand)<br />
{<br />
int[] pic = GetPics(hand);<br />
<br />
BubbleSort(pic); <br />
<br />
if (((pic[0] + 1 == pic[1]) || (pic[0] + 12 == pic[4])) && pic[1] + 1 == pic[2] && pic[2] + 1 == pic[3] && pic[3] + 1 == pic[4])<br />
return true;<br />
else<br />
return false;<br />
}<br />
<br />
static bool FourOfAKind(int[] hand)<br />
{<br />
int[] pic = GetPics(hand);<br />
<br />
BubbleSort(pic);<br />
<br />
if (((pic[0] == pic[1]) || (pic[3] == pic[4])) && pic[1] == pic[2] && pic[2] == pic[3])<br />
return true;<br />
else<br />
return false;<br />
}<br />
<br />
static bool FullHouse(int[] hand)<br />
{<br />
int[] pic = GetPics(hand);<br />
<br />
BubbleSort(pic);<br />
<br />
if ((pic[0] == pic[1] && pic[1] == pic[2] && pic[3] == pic[4]) || (pic[0] == pic[1] && pic[2] == pic[3] && pic[3] == pic[4]))<br />
return true;<br />
else<br />
return false;<br />
}<br />
<br />
static bool ThreeOfAKind(int[] hand)<br />
{<br />
int[] pic = GetPics(hand);<br />
<br />
BubbleSort(pic);<br />
<br />
if ((pic[0] == pic[1] && pic[1] == pic[2]) || (pic[1] == pic[2] && pic[2] == pic[3]) || (pic[2] == pic[3] && pic[3] == pic[4]))<br />
return true;<br />
else<br />
return false;<br />
}<br />
<br />
static bool TwoPairs(int[] hand)<br />
{<br />
int[] pic = GetPics(hand);<br />
<br />
BubbleSort(pic);<br />
<br />
if ((pic[0] == pic[1] && pic[2] == pic[3]) || (pic[1] == pic[2] && pic[3] == pic[4]) || (pic[0] == pic[1] && pic[3] == pic[4]))<br />
return true;<br />
else<br />
return false;<br />
}<br />
<br />
static bool Pair(int[] hand)<br />
{<br />
int[] pic = GetPics(hand);<br />
<br />
BubbleSort(pic);<br />
<br />
if ((pic[0] == pic[1] || pic[1] == pic[2]) || (pic[2] == pic[3] || pic[3] == pic[4]))<br />
return true;<br />
else<br />
return false;<br />
}<br />
<br />
static void CardReplace(int[] hand)<br />
{<br />
string s;<br />
do<br />
{<br />
Console.Write("How many cards would you like to replace (0-3): ");<br />
s = Console.ReadLine();<br />
} while (s != "0" && s != "1" && s != "2" && s != "3");<br />
<br />
int[] idxCardToReplace = new int[int.Parse(s)];<br />
for (int i = 0; i < idxCardToReplace.Length; i++)<br />
{<br />
do<br />
{<br />
Console.Write("Replace card ({0}/{1}): ", i + 1, idxCardToReplace.Length);<br />
s = Console.ReadLine();<br />
} while (s != "1" && s != "2" && s != "3" && s != "4" && s != "5");<br />
idxCardToReplace[i] = int.Parse(s);<br />
for (int j = i - 1; j >= 0; j--)<br />
if (idxCardToReplace[i] == idxCardToReplace[j])<br />
{<br />
Console.WriteLine("This card was chosen already");<br />
i--;<br />
break;<br />
}<br />
} <br />
<br />
int[] cardToReplace = new int[int.Parse(s)];<br />
Random rnd = new Random(); <br />
for (int i = 0; i < cardToReplace.Length; i++)<br />
{<br />
cardToReplace[i] = rnd.Next(0, 52);<br />
for (int j = 0; j < hand.Length; j++)<br />
if (cardToReplace[i] == hand[j])<br />
{<br />
i--;<br />
break;<br />
}<br />
for (int j = 0; j < i; j++)<br />
if (cardToReplace[i] == cardToReplace[j])<br />
{<br />
i--;<br />
break;<br />
}<br />
}<br />
<br />
for (int i = 0; i < idxCardToReplace.Length; i++) <br />
hand[idxCardToReplace[i] - 1] = cardToReplace[i];<br />
}<br />
<br />
static int PrintHandRank(int[] hand)<br />
{ <br />
int[] tmpHand = new int[hand.Length];<br />
for (int i = 0; i < hand.Length; i++)<br />
tmpHand[i] = hand[i];<br />
BubbleSort(tmpHand);<br />
<br />
Console.Write("Rank: ");<br />
if (Flush(tmpHand) && Straight(tmpHand))<br />
{<br />
Console.WriteLine("Straight flush");<br />
return 10;<br />
}<br />
else if (FourOfAKind(tmpHand))<br />
{<br />
Console.WriteLine("Four of a kind");<br />
return 7;<br />
}<br />
else if (FullHouse(tmpHand))<br />
{<br />
Console.WriteLine("Full house");<br />
return 6;<br />
}<br />
else if (Flush(tmpHand))<br />
{<br />
Console.WriteLine("Flush");<br />
return 5;<br />
}<br />
else if (Straight(tmpHand))<br />
{<br />
Console.WriteLine("Straight");<br />
return 4;<br />
}<br />
else if (ThreeOfAKind(tmpHand))<br />
{<br />
Console.WriteLine("Three of a kind");<br />
return 3;<br />
}<br />
else if (TwoPairs(tmpHand))<br />
{<br />
Console.WriteLine("Two Pairs");<br />
return 2;<br />
}<br />
else if (Pair(tmpHand))<br />
{<br />
Console.WriteLine("Pair");<br />
return 1;<br />
}<br />
else <br />
Console.WriteLine("Highest Card");<br />
return 0;<br />
}<br />
<br />
static int CalcPoints(int bet, int mult, int total)<br />
{<br />
switch (mult)<br />
{<br />
case 0:<br />
Console.WriteLine("You lost {0} points.", bet);<br />
break;<br />
case 1:<br />
Console.WriteLine("No win no lose.");<br />
break;<br />
default:<br />
Console.WriteLine("You won {0} points.", mult * bet);<br />
break;<br />
}<br />
total += bet * mult;<br />
Console.WriteLine("Total points: {0}", total);<br />
return total;<br />
}<br />
<br />
static int GetBet(int total)<br />
{<br />
int bet;<br />
Console.WriteLine("Total points: {0}", total);<br />
do<br />
{<br />
Console.Write("Enter bet (1-{0}): ", total);<br />
bet = int.Parse(Console.ReadLine());<br />
} while (bet < 1 || bet > total);<br />
return bet;<br />
}<br />
<br />
static void PrintMenu()<br />
{<br />
Console.WriteLine("Poker Project:");<br />
Console.WriteLine("-------------------");<br />
Console.WriteLine("(1) Play");<br />
Console.WriteLine("(2) Exit");<br />
Console.Write("Enter your choice: ");<br />
}<br />
<br />
static void HandleUser()<br />
{<br />
int[] hand = new int[5];<br />
<br />
string choice;<br />
int total = 100;<br />
int bet;<br />
int mult;<br />
<br />
do<br />
{<br />
Console.Clear();<br />
PrintMenu();<br />
choice = Console.ReadLine();<br />
Console.WriteLine();<br />
<br />
switch (choice)<br />
{<br />
case "1": <br />
bet = GetBet(total);<br />
total -= bet; <br />
Console.Clear();<br />
InitializeHand(hand);<br />
PrintHand(hand); <br />
mult = PrintHandRank(hand);<br />
CardReplace(hand);<br />
PrintHand(hand); <br />
mult = PrintHandRank(hand);<br />
total = CalcPoints(bet, mult, total);<br />
if (total == 0)<br />
{<br />
Console.WriteLine("Game Over.");<br />
goto case "2";<br />
}<br />
break;<br />
<br />
case "2":<br />
Console.WriteLine("Thank you for playing poker.");<br />
choice = "2";<br />
break; <br />
<br />
default:<br />
Console.WriteLine("Choice {0} is invalid, please try again..", choice);<br />
break;<br />
}<br />
Console.Write("Press Enter to continue..");<br />
Console.ReadLine();<br />
} while (choice != "2");<br />
<br />
}<br />
<br />
static void Main(string[] args)<br />
{<br />
HandleUser();<br />
}<br />
}<br />
}
|
|
|
|
|
When you posted this and you got the warning that your message was very long and you should consider cutting it down, did you actually pay any attention?
I'd love to help, but I'm not going to read through all that. If you have a specific question then we'd love to help.
One quick comment. Your first method is a bubble sort. What was wrong with the built in sorting mechanisms in .NET?
|
|
|
|
|
Colin Angus Mackay wrote: I'd love to help, but I'm not going to read through all that. If you have a specific question then we'd love to help.
I've started helping out here on somewhat of a regular basis. I've noticed that posters rarely surround their code with pre tags. Instead, they use the code tag or no tag at all. This makes it hard to read their code.
|
|
|
|
|
Leslie Sanford wrote: I've noticed that posters rarely surround their code with pre tags. Instead, they use the code tag or no tag at all.
The problem, and it's something you should take up with Chris if you want anything done is that the pre tag doesn't appear to be intended for code snippets. I'm not sure what to rename it as to make what it and the code tag are intended to do more clear, otherwise I'd've posted to the suggestions board a while ago myself.
--
CleaKO The sad part about this instance is that none of the users ever said anything [about the problem].
Pete O`Hanlon Doesn't that just tell you everything you need to know about users?
|
|
|
|
|
Yes Colin i saw this warning about long code and i appoligize for that.
May be you are right about bubble sort and it's not be included in code.
My question how to rebuilt this code in "structs". I began programm 4 months
ago and i don't have a lot of skills. But i have to rebuilt this to struct.
i want to do 3 or 4 structs : " Card", "CardDeck", "Hand" and may be "Game".
Card and CardDeck i think allright, but Hand that initializes 5 cards prints
and replaces old card to new not working, i don't know what to do.
May be somebody know source code or links to this.
Tnanks...
|
|
|
|
|