|
as i said - i'm not sure you need to - but if you want to
something like
for(int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
array[i,j] == dataGridView1[i,j].Value;
}
}
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
I created a project using .NET Framework 3.0 before I downloaded 3.5...
using C# on Visual Studio 08
Creating a windows program, a basic forms program
I have the following:
using System;<br />
using System.Collections;<br />
<br />
<br />
namespace Zombie_Zombie_Zombie<br />
{<br />
partial class Form1<br />
{<br />
protected override void Dispose(bool disposing)<br />
{<br />
if (disposing && (components != null))<br />
{<br />
components.Dispose();<br />
}<br />
base.Dispose(disposing);<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
<br />
private void InitializeComponent()<br />
{<br />
this.tabControl1 = new System.Windows.Forms.TabControl();<br />
...<br />
private System.Windows.Forms.RichTextBox outputRichText;<br />
private System.Windows.Forms.LinkLabel linkLabel14;<br />
<br />
class character<br />
{<br />
protected Hashtable charSheet = new Hashtable();<br />
protected Hashtable calcSheet = new Hashtable();<br />
protected Hashtable mutantStats = new Hashtable();<br />
protected Hashtable mutantPowers = new Hashtable();<br />
charSheet.Add("Name","")<br />
...<br />
charSheet.Add("Money", "");<br />
}<br />
<br />
}<br />
}<br />
<br />
Now I'm using this because that's the syntax given here: <a href="http://msdn.microsoft.com/en-us/library/system.collections.hashtable.aspx">MSDN Hashtable Class (System.Collections)
I had originally tried charSheet["Name"] = ""; because I was using Beginning C# Game Programming page 105 on Hashtables.
This is the error code I get:
<br />
Error 1 Invalid token '(' in class, struct, or interface member declaration C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Zombie Zombie Zombie\Zombie Zombie Zombie\Form1.Designer.cs 499 26 Zombie Zombie Zombie<br />
...<br />
Error 39 Invalid token '(' in class, struct, or interface member declaration C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Zombie Zombie Zombie\Zombie Zombie Zombie\Form1.Designer.cs 537 26 Zombie Zombie Zombie<br />
help please
|
|
|
|
|
From your code example, it is absolutely unclear which lines are in the class declaration and which are in the method flow (in InitializeComponent() ). If you try to declare a class (character ) from within a method or call a method (Hastable.Add ) from within a class declaration, the compiler won't buy it.
You can't do stuff like
void SomeFunction()
{
class SomeClass
{
}
}
or
class SomeClass
{
ht = new HashTable();
ht.Add(...);
}
My kind advice is that you should learn some basic softball programming first, then move on to OOP and C# and then move on to game development.
H.
|
|
|
|
|
lol. I learned oop over ten years ago on C++ before the ansi iso standard and just now trying to get back into it...
thanks for the help tho.
|
|
|
|
|
No offense meant I just couldn't decide if you screwed up copying the code example or if you screwed up writing the code. The latter would explain the compiler errors
Good luck, H.
|
|
|
|
|
i had forgotten that I was trying to build it using a template of sample code I was working with...
so I started again...
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 WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
public class character
{
protected Hashtable charSheet = new Hashtable();
protected Hashtable calcSheet = new Hashtable();
protected Hashtable mutantStats = new Hashtable();
protected Hashtable mutantPowers = new Hashtable();
public character()
{
}
charSheet.Add("Name","")
...
charSheet.Add("Money", "");
}
}
I still do not see what I'm doing. why won't it let me make a hashtable in the class character when it's apart of the namespace with System.Container ?
|
|
|
|
|
msheekhah wrote: charSheet.Add("Name","")
...
charSheet.Add("Money", "");
These two lines must be in a method, if you wish to avoid compiler errors.
Assignments and the like cannot just be in class scope, they must be in a method. Only declarations can be just in the class scope.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
My Project has references of Activeds and ADODB but as soon as i am building the setup it is asking for the Activeds and ADODB to be excluded. After these dlls are excluded the setup project is making a setup of the program. Now that i have excluded these dlls, the application is not running on another computer after the setup installation is complete.
Thanks
Shweta
|
|
|
|
|
Why are you excluding required DLLs. If you were delivering a car would you remove the battery and expect it to work? Have a 1 for a really stupid question.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Folks,
This is sorta tough to describe so please bear with me.
I have an Excel file that shells out to an exe on the lan. It works for me but for some others, as soon as the app tries to instanciate a custom class, I get a cryptic SECURITY ERROR - no inner exception. And when I say cryptic , it doesn't even seem that the constructor is called (tried throwing exceptions as soon as I entered NEW but didn't seem to register).
I know about using the ConfigWizards.exe to adjust inTRAnet security but no avail.
Any ideas?
|
|
|
|
|
Hi
i've wrote a sample database app, which use a single dataSet object in all over of the application (It's static). when a form open, the appropriate table of that dataset fill out and when form closing, that table clear.
my question is that Is this best practise (where performance & overhead is important) ?
u can download it via this link (http://rapidshare.com/files/227688281/Sample_Singleton_Pattern.rar.html[^]). plz run and test it and tell me your comments.
Notes :
1. Plz first execute DbScript.sql to create 'Test' database and stored procedures
2. Use vs 2008 to work with sample project.
3. Change connection string in app.config.
i'm waiting for your comments.
Thanks
|
|
|
|
|
I'm not saying that your job is bad. but...
I know better ways to do that, LinQ for example is an excelente way to work with data...
Preparing for 70-536
|
|
|
|
|
Yeah, probably not the worst way, but not the best either.
I very rarely use a DataSet at all; I think they were only created to make demonstrating VS and book writing easy.
They're like VB; they make doing easy things appear even easier, but quality results require more robust/lower-level techniques.
|
|
|
|
|
I actually needed a dataset recently, the proc was returning 2+ tables and was surprised my DAL had a method to support it. Datatables are the basic container in my DAL.
I found performance dropped off dramatically when returning multiple tables from a single proc.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If performance and overhead is important, then don't use datasets (IMHO).
Use a datareader to get the data and populate objects (and collections thereof) and return them.
Do whatever is required to the objects, and have methods to re-populate the DB from teh new values.
Depending on your requirements you may need to have your objects implement interfaces or inherit from base classes that 'know' if they are new (to the DB) or have been changed - but that's fairly simple in most cases (again, without knowing the requirements it's difficult to judge)
The important thing, I think, is that if performance and overhead are important, writing it yourself will always be more efficient (OK, assuming you write it well) than a 'generic' solution.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Hi,
I 'm using c#.net(3.0),I want to extract audio from an AVI file(Audio/Video file *.avi) in wav format(*.wav) could anyone please tell how to do this using C#.net.
I'm using the AviFile.dll provided with source code at this link http://www.codeproject.com/KB/audio-video/avifilewrapper.aspx but the given example is not working with all *.avi.It is only working with the given test data.
thank you
|
|
|
|
|
I know nothing about how to do this in C# but one way or another, you will have to use some external library or program. In that case I suggest you dig some information on typical video-processing command line programs (mencoder, ffmpeg, others) and if you run then with the right switches, the'll do exactly what you need. I'm sure mencoder can extract audio, I just don't know the exact switches - google this.
If you want this in C# from scratch, you are looking at a LOT of work.
H.
|
|
|
|
|
It says I can't power up a double and a double
double a = 1.8;
double b = 2.9;
a = a ^ b ;
any ideas?
|
|
|
|
|
b cannot be a double, that is correct.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Use Math.Pow() instead.
H.
|
|
|
|
|
|
<code>^</code> is the logical <a href="http://msdn.microsoft.com/en-us/library/zkacc7k1(VS.80).aspx">XOR</a>[<a href="http://msdn.microsoft.com/en-us/library/zkacc7k1(VS.80).aspx" target="_blank" title="New Window">^</a>] operator. As was mentioned upthread you need to use <code>Math.Pow</code>.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Did you ever screw that one up
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I wrote a program that will search AD and pull all the users int a combo box and then you select the user to unlock and it unlocks the locked out account awesome !
to make things quicker i want to know how could i only populate the combo box with locked accounts ?
thank you for your time
|
|
|
|
|
I have code for a calculator, and continue to get an error that I cannot seem to find.
The error: The type or namespace name 'ArrayList' could not be found(are you missing a using directive or an assembly reference)
I have partial classes, delaring the following in the Calculator.Designer.cs
private string m_value;
private ArrayList m_store;
the rest of the code below is in the Calculator class:
Can someone see what might be missing?
Here is the code:
public partial class Calculator : Form
{
public Calculator()
{
InitializeComponent();
m_value = "";
m_store = new ArrayList();
}
private void btnSeven_Click(object sender, EventArgs e)
{
AddToArray(btnSeven);
}
private void btnEight_Click(object sender, EventArgs e)
{
AddToArray(btnEight);
}
private void btnNine_Click(object sender, EventArgs e)
{
AddToArray(btnNine);
}
private void btnFour_Click(object sender, EventArgs e)
{
AddToArray(btnFour);
}
private void btnFive_Click(object sender, EventArgs e)
{
AddToArray(btnFive);
}
private void btnSix_Click(object sender, EventArgs e)
{
AddToArray(btnSix);
}
private void btnOne_Click(object sender, EventArgs e)
{
AddToArray(btnOne);
}
private void btnTwo_Click(object sender, EventArgs e)
{
AddToArray(btnTwo);
}
private void btnThree_Click(object sender, EventArgs e)
{
AddToArray(btnThree);
}
private void btnZero_Click(object sender, EventArgs e)
{
AddToArray(btnZero);
}
//create method for array to calculate
private void AddToArray(Button btn)
{
//m_value this to set the value
m_value += btn.Text;
//set label lblResult = " to display it to user
lblResult.Text += btn.Text;
//make all enabled to use it
SetEnableOperatorBtns(true);
}
private void btnAdd_Click(object sender, EventArgs e)
{
AddOperatorToArray(btnAdd);
}
private void btnSubtract_Click(object sender, EventArgs e)
{
AddOperatorToArray(btnSubtract);
}
private void btnMultiply_Click(object sender, EventArgs e)
{
AddOperatorToArray(btnMultiply);
}
private void btnDivide_Click(object sender, EventArgs e)
{
AddOperatorToArray(btnDivide);
}
// Method to add the operator to the array
private void AddOperatorToArray(Button btn)
{
//add the value to the arrayList
m_store.Add(m_value);
//display the Result to user
lblResult.Text += btn.Text;
//make the value empty
m_value = "";
//add the opeator to arrayList
m_store.Add(btn.Text);
//make the decimal button enabled
btnDecimal.Enabled = true;
//call the SetEnableOperatorBtns(false); to make all operators unenabled
SetEnableOperatorBtns(false);
}
private void Reset()
{
m_value = "";
lblResult.Text = "";
m_store.Clear();
btnDecimal.Enabled = true;
}
private void SetEnableOperatorBtns(bool enable)
{
btnAdd.Enabled = enable;
btnSubtract.Enabled = enable;
btnMultiply.Enabled = enable;
btnDivide.Enabled = enable;
btnEquals.Enabled = enable;
}
private void btnDecimal_Click(object sender, EventArgs e)
{
//Add to arrayList
AddToArray(btnDecimal);
btnDecimal.Enabled = false;
}
//m_result here take the first element in m_store if this element is
//operator like +*-/, Exception gives us error else if will take the
//digits or dot point
private void btnEquals_Click(object sender, EventArgs e)
{
try
{
// add value to the arrayList
m_store.Add(m_value);
// add operator to the arrayList
m_store.Add(btnEquals.Text);
//take the first element in the array, make sure its a digit
//and then save it on m_result, else it will give exception
float.m_result = float.Parse(m_store[0].ToString());
//loop extracts all elements in arrayList then checks it
//if the element is operator it will calculate the prefix and
//postfix and give us the result
//for loop on arrayList and check for element if equal to opera or not
//if equal operator
for (int i = 0; i < m_value.Length; i++)
{
if(m_store[i].ToString() == "+")
{
lblResult.Text = "";
m_result += float.Parse(m_store[i+1].ToString());
lblResult.Text = m_result.ToString();
}
else
if(m_store[i].ToString() == "-")
{
lblResult.Text = "";
m_result -= float.Parse(m_store[i].ToString());
lblResult.Text = m_result.ToString();
}
else
if(m_store[i].ToString() == "*")
{
lblResult.Text = "";
m_result -= float.Parse(m_store[i].ToString());
lblResult.Text = m_result.ToString();
}
else
if(m_store[i].ToString() == "/")
{
lblResult.Text = "";
m_result -= float.Parse(m_store[i].ToString());
lblResult.Text = m_result.ToString();
}
}
m_store.Clear();
m_value = lblResult.Text;
for(int i=0; i < m_value.Length; i++)
{
if(m_value[i].ToString() == ".")
{
btnDecimal.Enabled = false;
break;
}
else
{
btnDecimal.Enabled = true;
}
}
btnEquals.Enabled = false;
}
catch(Exception exception)
{
MessageBox.Show(exception.Message, "Error");
}
}
private void btnClear_Click(object sender, EventArgs e)
{
Reset();
}
|
|
|
|