|
That is so vague I can't offer any effective help, except to say from your description I see little opportunity to run out of memory, barring a huge mistake in your code. Unless each of your shapes resemble a detailed map of the world, rather than some elementary rectangle, circle, etc.
An extremely wild guess could be an infinite loop where you allocate some memory and keep doing that, e.g. inside a property getter/setter or a method that calls itself (which would in the end also run out of stack).
Suggestions:
1. look at all the details of the actual exception, in particular the line number it mentions; then watch the related code.
2. when necessary, ask specific questions, documented with sufficient information and relevant code snippets.
|
|
|
|
|
Hello,
I am working on a math program for my daughter in C# using a Form. Here is the gist of my program:
1) Create random numbers.
2) Add numbers together. Compare to user input.
3) Tell user if question was answered correctly.
I can get the program to cycle through once successfully. I can't figure out how to loop through a series of 50 questions though. When I've tried to loop it, I either end up on question 50 or suffer through an infinite loop.
The idea is to use the 'checkAnswer' button to let the user know if the question was answered correctly and then move on to the next question. However, I have yet to figure out a way to signal to the rest of the program (return value from button click?) that the button has been pressed. I have included the code.
If anyone could point me in the right direction, I would greatly appreciate it. Also, this is the first time I've posted in a programming forum so I've left out any pertinent info please let me know!!!
namespace Math
{
public partial class NewMathForm : Form
{
public NewMathForm()
{
InitializeComponent();
int questionCounter = 1;
for (; questionCounter < 50; )
{
addition(ref questionCounter);
}
}
private void sumTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
sumTextBox.SelectionStart = 0;
}
public void shuffle(ref int[] array)
{
Random rng = new Random();
int count = array.Length;
while (count > 1)
{
int k = rng.Next(count);
count--;
int temp = array[count];
array[count] = array[k];
array[k] = temp;
}
}
private void parseNumbers(ref int[] array)
{
double addend1 = 0;
double addend2 = 0;
string number;
char num1;
char num2;
for (int count = 0; count < 50; count++)
{
number = array[count].ToString();
num1 = number[0];
int length = number.Length;
if (length < 2)
{
char zero = '0';
num2 = zero;
}
else
num2 = number[1];
addend1 = System.Char.GetNumericValue(num1);
addend2 = System.Char.GetNumericValue(num2);
array[count] = Convert.ToInt32(addend1);
count++;
array[count] = Convert.ToInt32(addend2);
}
}
private void addition(ref int tickUp)
{
int[] numbers = new int[100];
int counter = 0;
int questionCounter = 1;
int numberOfQuestions = 50;
for (counter = 0; counter < 100; counter++)
{
numbers[counter] = counter;
}
shuffle(ref numbers);
parseNumbers(ref numbers);
if (sumTextBox.Text == "")
{
addendOneLabel.Text = numbers[questionCounter].ToString();
addendTwoLabel.Text = numbers[questionCounter + 1].ToString();
}
tickUp++;
}
private void checkAnswerButton_Click(object sender, EventArgs e)
{
checkAnswer();
}
public void checkAnswer()
{
int sum = Convert.ToInt32(sumTextBox.Text);
int number1 = Convert.ToInt32(addendOneLabel.Text);
int number2 = Convert.ToInt32(addendTwoLabel.Text);
int answer = number1 + number2;
if (answer == sum)
correctAnswer();
else
incorrectAnswer(answer);
sumTextBox.Text = "";
}
private void correctAnswer ()
{
MessageBox.Show ("That is correct!");
}
private void incorrectAnswer (int sum)
{
MessageBox.Show ("That is incorrect! The correct answer is " + sum + ".");
}
}
}
|
|
|
|
|
for (int count = 0; count < 50; count++)
{
array[count] = Convert.ToInt32(addend1);
count++;
array[count] = Convert.ToInt32(addend2);
You are using the count variable for two different purposes and by incrementing at this point you are corrupting your loop. You should use a separate variable for your array index.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
int x[10],sn=0,sp=22,counter;
int bqueens(int k,int i)
{
int j;
for(j=1;j
|
|
|
|
|
This is not a well framed question (If you are trying to ask one!)
We cannot work out what you are trying to do/ask from the post. Please edit your question and provide better information.
|
|
|
|
|
This looks like C/C++ code not C#. Also a quick Google for your title will lead you to lots of useful information.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
a) Not a question - please refer to the site guidance about asking a question.
b) Not c# - wrong forum
c) Not complete code.
d) Not formatted code
e) This is a well known problem and easily googled.
|
|
|
|
|
|
hi, I want sorce code of Image Encryption (with chaos signals) in C#, please help me.
|
|
|
|
|
Danial C wrote: I want sorce code of Image Encryption
It does not work like this here.
Here is what is expected of enquirers:
1. TRY first what you want to do! You may not find it too difficult.
2. Formulate what was done by you that looks like an issue/not working.
So, try them and tell if you face issues.
|
|
|
|
|
Hi I am new in C# I try an application like this
"
Title="Window1" Height="300" Width="300">
<grid>
<path name="myPath" stroke="Black"
="" strokethickness="1">
"
and
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DynamicPoint002
{
///
/// Interaction logic for Window1.xaml
///
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = new Point(10, 50);
LineSegment myLineSegment = new LineSegment();
myLineSegment.Point = new Point(200, 70);
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myLineSegment);
myPathFigure.Segments = myPathSegmentCollection;
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
myPathFigureCollection.Add(myPathFigure);
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = myPathFigureCollection;
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
}
}
}
but I do not understand why did not show my the line defined already?
Thanks a lot!!!
H.
|
|
|
|
|
|
Hi friends,
Is possible to choose a instalation directory for my c# aplications ? (I´m using VCS2008)
all my apps istalls on a default user directory
thanks in advance
marcelo campos
|
|
|
|
|
Yes, of course. Most installers default to Program Files | Company | Product Name , but you can override this.
/ravi
|
|
|
|
|
No, it´s installing on a user sub path not to Program Files | Company | Product Name,
I´m using default C# 2008 installer
thanks
|
|
|
|
|
I use the free version of Advanced Installer[^] to install my app[^]. Although the default installation dir is Program Files | Company | Product Name , the app can be installed to any folder.
/ravi
|
|
|
|
|
I created a simple software program in C#, and would like to add a Calendar to it. Something that could have a monthly view (with a line or two written on particular days), and a daily view (or simply a popup that displays the events for that day, when clicked in monthly view). I'd like to be able to add events to specific dates, and then save the calendar to load up later.
I've searched high and low for any kind of tutorial, sample, or source code on how to do this, but haven't found much of anything that works. The closest was this component: http://www.accelerated-ideas.com/NET/aiFreeNETComponents_AICalendar.aspx, which would actually work perfect if it didn't freeze up.
I haven't done much in the saving area with c#, except writing/reading from an xml file, I'm assuming this probably won't work though with saving a calendar. Any ideas, tips, thoughts, links to resources, etc. on which direction to take is greatly appreciated! Thanks in advance.
|
|
|
|
|
There's no reason why you can't save calendar data to an XML file. However, you may want to consider a database for robustness and scalability.
Regarding UIs to display a calendar view, see these excellent CP controls:
And of course this classic: A Professional Calendar/Agenda View That You Will Use[^]
/ravi
|
|
|
|
|
hello everyone. I have created panels modeled as sheets of paper on which I draw text. My current implementation creates a lot of sheets (panels) sufficient to draw all the text. It happens that sometimes I create about 100 panels to draw all the text. I have realised this is not a good idea as much of memory is used.
I would like to know any idea I can implement viewing of the text by creating smaller count of sheets, something like streaming the text so that I draw only those once that become visible as the user scrolls the page. I'm finding it difficult to implement this.
Any sample code or idea on how I can implement this? I want it to work like that of Microsoft Word or Adobe Reader which is even capable of opening documents of 500 or 1000 pages. Thanks in advance.
|
|
|
|
|
You only need a small amount of painted panels, as many as you can possibly see at any one time.
So you need to figure which pages are visible and generate those, not the invisible ones.
And you can destroy the ones that become invisible (due to scrolling in the document); or you could keep a small cache of say 10 panels, so scrolling back and forth goes a bit faster.
|
|
|
|
|
Hi,
I have a gridview and a panel. the data in the gridview are the links of the names. When i click any link of the row of that gridview, based on the program, it should show or hide the panel. But the problem is when i first click the link, panel is showing or hiding based on which link i clicked but when i click another link from the gridview, it is not executing its function. Any idea why is that?
suchita
|
|
|
|
|
Probably a bug. Can you post the relevant code?
Bastard Programmer from Hell
|
|
|
|
|
Hi this is chandra.
I have one question. I have some predefined Chat controls. I want to create a chat control as a user control in c# by assigning some properties like chat name, chat width, chat height.How can i create this. can any one please suggest me on this.
Thanks
Chandrasekar
|
|
|
|
|
See this[^] tutorial on user controls at MSDN.
/ravi
|
|
|
|
|
+5, as it is the correct answer. As it reads, the user wants to put something in a UserControl.
Bastard Programmer from Hell
|
|
|
|