|
Mine is.
Opened app.config, there it is.
Remove the setting, reopen app.config - it's gone
Everything makes sense in someone's mind
|
|
|
|
|
No. App.config is what it says it is: application configuration info. That's what the designer uses and that's what the compiler generates your settings class from.
When you save user settings, the actual values get written out to:
C:\<username>\AppData\Local\<company name>\<app.exe>_url_<hash>\<version>\user.config
Go look there
|
|
|
|
|
Hi,
Below is the declaration at class level.
<pre lang="c#">int[] PossibleValues = new int[6];
int[][] JaggedArray = new int[50][];
int JaggedVar = 0;</pre>
Then in a function, I am assigning PossibleValues array to Jaggedarray like this.
[PossibleNumbers is a function that returns an array of possible numbers for a cell in a grid.]
<pre lang="c#">PossibleValues = PossibleNumbers();
JaggedArray[jaggedVar] = PossibleValues;
jaggedVar++;</pre>
The number of elements in PossibleValues in each iteration may vary,but it will never exceed 6.I dont want Jaggedarray to store zeros of PossibleValues so I changed the code to:
<pre lang="c#">PossibleValues = PossibleNumbers();
for (int i = 0; i < PossibleValues.Length; i++)
{
if (PossibleValues[i] != 0)
{
JaggedArray[jaggedVar][i] = new PossibleValues[i];
}
}
jaggedVar++;</pre>
But this gives null reference exception at
JaggedArray[jaggedVar][i] = new PossibleValues[i];
I searched it over the internet and came to know that JaggedArray remains null hence values cannot be assigned this way.How to resolve this?
Any help would be appreciated.
Thanks in advance!
|
|
|
|
|
There seems to be some inconsistencies in your code (and the formatting needs to be fixed). I cannot get the above to compile cleanly as your variable names are not all correct: you have JaggedVar defined at the top. but use jaggedVar (case change) later. You are also incrementing jaggedVar outside your for loop.
Also the statement
JaggedArray[jaggedVar][i] = new PossibleValues[i];
does not make sense.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
I'm not sure if I understood everything correctly, but if you don't want PossibleValues to contain a number 0. I think you should change the method "PossibleNumbers" to return an array that does not contain a 0.
I also think 'new PossibleValues[i]' is wrong. PossibleValues[i] has a value you cannot re-instantiate it.
Probably you need something like (pseudocode):
if value = 0
CreateNewRandom int between 1 and x
PossibleValues[i] = randomint
JaggedArray[jaggedVar][i] = PossibleValues[i]
hope this helps.
V.
|
|
|
|
|
Thanks for your reply.
I m implementing Sudoku that computer will play after the user inputs certain numbers in its grid. The logic that I m following is that the function PossibleNumbers() calculates the numbers that are possible for each cell of 9x9 grid of Sudoku.The number of numbers possible for each cell may Vary. If for example 1, 3 are numbers possible for one cell, then 2,3,4 maybe possible for other cell.PossibleNumbers() runs for every cell of the grid. Here is its implementation
private int[] PossibleNumbers()
{ int[] PossibleNumbers = new int[] { 1, 2, 3, 4, 5, 6 };
Array.Clear(PossibleValues, 0, 6);
int k = 0;
for (int i=0 ; i < PossibleNumbers.Length; i++)
{
int count = 0;
for (int j=0 ; j < tempArray.Length; j++)
{
if (tempArray[j] == Convert.ToInt32(PossibleNumbers[i]))
{
count++;
break;
}
}
if (count == 0)
{
PossibleValues[k] = PossibleNumbers[i];
k++;
}
}
return PossibleValues;
}
The size of PossibleValues is set to 6 at the time of initializing it.so if two numbers are possible for a cell then the remaining 4 indexes will contain zero. And this is the problem. How do I go about it.
Please Help!
Thanks
|
|
|
|
|
This is the implementation. The inconsistency in variable declaration and usage was a typo. How do I proceed now ?
PossibleValues = PossibleNumbers();
for (int i = 0; i < PossibleValues.Length; i++)
{
if (PossibleValues[i] != 0)
{ JaggedArray[jaggedVar][i] = PossibleValues[i];
}
}
jaggedVar++;
|
|
|
|
|
ariez88 wrote: How do I proceed now ?
With what?
V.
|
|
|
|
|
With assigning PossibleValues to Jaggedarray without encountering Null Reference Exception.
|
|
|
|
|
If it is for a Sudoku I'm not sure from your code, how you'll implement it.
However I would use the following logic.
Create a 9x9 integer array which will be your playboard.
After that you'll need to create a "solved" sudoku (I think there is only one solution, not sure)
Somewhere on the internet you should be able to find how many digits you need where to be able to solve the soduku. Create a copy of the solution, remove the digits that are not necessary and voila, your sudoku is ready.
There is, in my opinion, no need for a jagged array.
Hope this helps.
V.
|
|
|
|
|
Actually, the user will input the numbers that are normally given in any Sudoku game,
once those numbers are entered, the computer will present the solution using If-Else logic throughout the game, calculating the possible numbers for each cell of the 9x9 grid.
|
|
|
|
|
That doesn't seem like a bad solution, but still no need for jagged array's, you need to use a fixed multidimensional array of 9x9.
V.
|
|
|
|
|
Hi All !
I have a pdf file, place in the debug directory (in any drive) . I want to open this file with any full path :
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
Process.Start(appPath + "\\Debug\\HelpFile.pdf");
But I have an error that can not file file ,
pl z help me !
thanks in advance !
|
|
|
|
|
Message Removed
modified 8-May-12 16:18pm.
|
|
|
|
|
@"..\Debug\HelpFile.pdf");
It's works !
Thanks in advance!
Regards !
|
|
|
|
|
Yeah, but when you deploy the application in production, it'll fail! Unless you have the Debug folder created when you install the application, BOOM!
|
|
|
|
|
|
thanx !
|
|
|
|
|
How do you create and link multiple forms in c#?
|
|
|
|
|
Could you be more specific? Link the forms to what? Are these different forms, or multiple forms of the same type?
Basically, tell us what scenario you are trying to satisfy here, and tell us what code you currently have. Without this, we can only guess what you really want, and could steer you in completely the wrong direction.
|
|
|
|
|
Form1 form = new Form1();
form.ShowDialog();
|
|
|
|
|
FORM1 FR = NEW FORM1;
FR.SHOW();
|
|
|
|
|
Been stuck with this for too long now and thought I ask for help. From reading a bunch of threads this seems trivial for you guys. I am not on some homework, just doing it out of self interest following a tutorial at csharpskolan.se
I do know how to make a windows form to generate a number using two numericUpDown boxes but I though I try make a dice program and pick the number of sides out of a comboBox. I have added 3 sided dice, 4 sided dice and so on using the design mode but I do not know how to put the value (1, 4) to the 3 sided dice selection for example.
Feels like I am getting stuck making the method, to call it depending on how many times I want to roll the 3 sided dice. I am going to have the output to a richTextBox.
What I am using is a comboBox(dice sides), textBox(number of times to roll), richTextBox(to diplay the value) and a button to generate it.
This is what I got after redoing it so many times.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Dice
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
var random = new RollDice();
}
}
public class RollDice
{
public int RandomDice(Int32 numberOfSides, Int32 numberOfTimes)
{
Random rndGen = new Random();
for (int i = 0; i < numberOfSides; i++);
int randomT3;
int randomT4;
int randomT5;
int randomT6;
randomT3 = rndGen.Next(1, 4);
randomT4 = rndGen.Next(1, 5);
randomT5 = rndGen.Next(1, 6);
randomT6 = rndGen.Next(1, 7);
}
}
}
modified 8-May-12 8:35am.
|
|
|
|
|
Here you go.
public static int RandomDice(Int32 numberOfSides, Int32 numberOfTimes)
{
int total = 0;
Random rndGen = new Random();
for (int i = 0; i < numberOfTimes; i++)
{
total = total + rndGen.Next(1, numberOfSides + 1);
}
return total;
}
|
|
|
|
|
Thanks a bunch, now it makes sence. I have been staring myself blind at this. I added a piece of code to the random but I am unsure what it does.
Random rndGen = new Random((int)DateTime.Now.Ticks);
To keep the precision on "random"?
|
|
|
|