|
|
there some error when i klik mouse in pc client, the error on this code
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
|
|
|
|
|
It means you should read this[^] before posting anything else.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hello,
I created an object "polzisce" from a class called Matrika(this is class that creates two dimensional array) and it's constructor takes two parameters.
Those two parameters are actualy X an Y axis and they are not fixed size.
public class Matrika
{
//constructor
public Matrika(int x, int y)
{
int[,] matrika = new int[x, y];
}
}
static void Main(string[] args)
{
Matrika polzisce = new Matrika(5, 5);
}
The question is:
Is object "polzisce" actualy two dimensional array after it is created?
How can i get that two-dimensional array "matrika" from constructor?
Thanks! Alen.
|
|
|
|
|
av7254 wrote: Is object "polzisce" actualy two dimensional array after it is created?
No, it HAS_A two-dimensional array.
av7254 wrote: How can i get that two-dimensional array "matrika" from constructor?
If that's what you want, then why create Matrika at all?
On the other hand, you could write a converter for it.
But why not simply write a static method that takes the two parameters and creates the array?
|
|
|
|
|
your way is simplier but, i want to do it like this.
all i want is to get the x and y value from constructor.
Use cases:
Matrika polzisce = new Matrika(10,20);
Matrika polzisce = new Matrika(5,2);
maybe:
Matrika polzisce = new Matrika(1000,1000);
in this case: Matrika polzisce = new Matrika(5,5);
Constructor runes first when object is created and contains varibles x=5 and y=5(actualy limits of array). I need those two to create two-dimensional array.
I don't know how to access those varibles in the constructor, that i can create 2d array and that object "polzisce" will contain 2d array 5x5
Tnx for all other posts!
I appreciate!
|
|
|
|
|
Not exactly a difficult thing to do: it is pretty common:
Using your original code:
public class Matrika
{
public int[,] arrayOfInts;
public Matrika(int x, int y)
{
arrayOfInts = new int[x, y];
}
}
static void Main(string[] args)
{
Matrika polzisce = new Matrika(5, 5);
for (int x = 0; x < 5; x++)
{
for (int y = 0; y < 5; y++)
{
Console.WriteLine(polzisce.arrayOfInts[x, y]);
}
}
} Note that it is not considered good practice to declare the array as public: I did this only to simplify this example.
Note also that the ints are not initialised, so they will all be zero.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Thanks!
i have solved this thing it is realy preety simple
<br />
public class Matrika<br />
{<br />
public int mat_x;<br />
public int mat_y;<br />
public Array matrika;<br />
<br />
public Matrika(int x, int y)<br />
{<br />
mat_x = x;<br />
mat_y = y;<br />
matrika = Array.CreateInstance(typeof(int), x, y);<br />
{<br />
But, why did you say that public atributes are no ok?
|
|
|
|
|
av7254 wrote: why did you say that public atributes are no ok
This may take a little while to explain:
Assume you have a class: MyClass which contains a string and an int.
public class MyClass
{
public string UserName;
public int UserID;
....
}
You write your class, you test it, you are happy it works.
So happy, you use it to handle all the user identity work in your entire app!
Then the boss comes along, and says he wants the user name to be in two parts in the database: First name, and second name. Oh, and the userID is not an int, it's going to be a GUID.
How many classes do you have to change to implement this? How much code to you have to change, and test, and document?
If instead you had written the class as:
public class MyClass
{
private string userName;
public string UserName
{
get { return userName; }
set { userName = value; }
}
private int userID;
public int UserID
{
get { return userID; }
set { userID = value; }
}
}
When your dumb boss comes along with his changes, how much rework is there to do? Only the one class, because you can change the internals of MyClass without affecting the outside world:
public class MyClass
{
private string firstName;
private string lastName;
public string UserName
{
get { return firstName + " " + lastName; }
set
{
string[] names = value.Split(' ');
if (names.Length != 2)
{
throw new ApplicationException("Name must have first and last components");
}
firstName = names[0];
lastName = names[1];
}
}
private GUID userID;
public int UserID
{
get { return userID.GetHash(); }
set { userID = GetGUID(value); }
}
}
This is one of the cornerstones of OOP - encapsulation. Never expose your internals more than you have to!
When you are starting off, it seems like a lot of fussing about over nothing! But it very quickly becomes second nature, and does give real benefits - almost from day one. If nothing else, it forces you to think about how your class will be used, and what you want to expose to the outside world. Very often, this affects the internal design in a good way, by the realization that a small change in the original plan can give a more flexible class with wider applications. This leads to more code re-use, and thus better reliability.
I hope that made some sense!
[edit]userID changed to GUID in last example - forgot that when I cut and pasted[/edit]
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Maybe you should google encapsulation, since I think that is what your trying to do.
|
|
|
|
|
polzisce isn't two dimensional array..
matrika is two dimesional, and if you want to access it make it member of class and write a method..
|
|
|
|
|
jayantbramhankar wrote: matrika is two dimesional
No it isn't.
modified on Friday, March 19, 2010 3:41 PM
|
|
|
|
|
int[,] matrika = new int[x, y];
It's not? Granted, there is no word "dimesional", but it seems 2D to me.
|
|
|
|
|
Sorry, I didn't see the lowercase m.
|
|
|
|
|
So, how do i make it member of class, that will conatain x=5 and y=5 in this case.
"polzisce" has to be object wich contains a 2d array wich is specified with this Matrika polzisce = new Matrika(5,5);
Tnx for your answers
|
|
|
|
|
I'm still not sure what you want, but how about this:
public class Matrika
{
private readonly int x ;
private readonly int y ;
public Matrika
(
int X
,
int Y
)
{
this.x = X ;
this.y = Y ;
return ;
}
public int[,]
GetArray
(
)
{
return ( new int [ this.x , this.y ] ) ;
}
}
Matrika m = new Matrika ( 5 , 5 ) ;
int[,] polzisce = m.GetArray() ;
|
|
|
|
|
Hello,
I already use a graphic library (named Irrlicht) with a C# package called Irrlicht.NET (with a file Irrlicht.NET.dll and Irrlicht.NET.xml)
The libary is open source, and has recently delivered a new release.
But the .NET package has not been released (done probably by an other team)
How can I build the new release for C# .net ?
Best regards.
|
|
|
|
|
pedefetoll wrote: How can I build the new release for C# .net
How do you build the C++ code base to use with C#? Or, how do you get the C# source and build it? Did you ask the Irrlicht developer team?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
The C++ code with project files is full available on following site :
(see at http://irrlicht.sourceforge.net/downloads.html)
But I don't know how to convert documented C++ API for managed application (like MS C#).
Best regards
|
|
|
|
|
pedefetoll wrote: convert documented
Ah. You do not want to do that. What you would have to do is to go through the source line by line and translate it to its C# equivalent. Probably a big task. I think that what you really want to do is to take the C++ DLL and use it in your C# project. The keyword you are looking for is P/Invoke. Plenty of articles around that show you how to do that.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Hi All,
I have two C# windows application, both are reading .csv file and doing some processing, however there is one difference between both .csv file. One .csv file is using comma (,) as delimiter (separater) and other .csv file is using |(Pipe) character as delimiter (separater), so basically that is customized seperater.
Both .csv file is used by my two different C# windows application.
Now here is a problem.
My first application used .csv file which has comma(,) as seperater and i am using provider as "Microsoft.Jet.OLEDB.4.0" to reading that file with following connectionstring:
string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + csvfile.Directory.FullName + ";Extended Properties='text;HDR=Yes'";
As by default it's comma, so i don't have to do any changes in my registry to read this file, it's simple but problem came when i am using my other C# windows application.
Second C# windows application is using other .csv file which has |(Pipe) character as seperater(delimiter). To read this type of .csv file i used following connection string
string textConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"" + StrInputCSVFile + "\";Extended Properties='text;HDR=No;FMT=Delimited';";
As well as in the registry i specified (|) delimiter at following place:
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Jet \ 4.0 \ Engines \ Text
i defined "Format" = "Delimited(|)" and second C# application able to read .csv file in correct way but now the problem is that it screwed up my first C# application as it is using comma as seperater.
Is there a way to define multiple custom delimiter under registry setting at following place
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Jet \ 4.0 \ Engines \ Text
like Delimited("|",",") etc or some thing like that??
I tried that but it didn't work.
My questions are :
- how can my both C# application should work without effecting each other?
As i said , one is having comma(,) as sepearter(delimiter) in .csv file and other is having (|) pipe as sepearter, how can my two different application can work at it's own without effecting each other?
- Currently as i defined delimited(|) in above mentioned registry setting so it screwed up first application and my first application is NOT able to read .csv file (which has comma(,) as delimiter)
- Is there a way to define Multiple delimiter in registry settings at above mentioned location at registry?
I don't want to use scheme.ini file at all.
Pls. help me out to resolve this issue.
Thanks in advance.
|
|
|
|
|
montu3377 wrote: delimiter under registry
Do you have to use the registry? There are easier/better ways to accomplish this other than using a registry setting.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Hi,
Can you tell me what are easier ways? I am using following code :
//Taking connection using to .csv file
string textConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"" + StrInputCSVFile + "\";Extended Properties='text;HDR=No;FMT=Delimited';";
//assigning to oledbconnection string
OleDbConnection conn = new OleDbConnection(textConnectionString);
// Opening connection
conn.Open();
//selecting rows from .csv file
sql_select = "Select * from " + InputCSVFile.ToString().Trim() ;
//Creates the data adapter
OleDbDataAdapter obj_oledb_da = new OleDbDataAdapter(sql_select, conn);
//Fills dataset with the records from CSV file
obj_oledb_da.Fill(ds);
As i have (|) pipe character in my .csv file , so i am specifying (|) pipe sepearter in registry setting otherwise i will NOT get correct parsed values.
Pls. let me know if you have some other way rather than this way??
I am eager to seeing that.
Thanks a lot for reply.
|
|
|
|
|
montu3377 wrote: way rather than this way
Take a look at this article, A Fast CSV Reader[^] and see if that is fills your need. You can use whatever delimiter you want.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Is to use different extensions for your file types to determine whether a pipe or a comma is used as the delimiter.
|
|
|
|
|