|
The Java rectangular array in your example is a special case in Java since Java only has jagged arrays (arrays of arrays), not multidimensional arrays, but allows a special rectangular jagged array initialization.
The C# equivalent to this is:
[code]//ORIGINAL LINE: private int[][] avtomat = new int[maxState][256];
//JAVA TO VB & C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
private int[][] avtomat = RectangularArrays.ReturnRectangularIntArray(maxState, 256);
//----------------------------------------------------------------------------------------
// Copyright © 2008 - 2010 Tangible Software Solutions Inc.
// This class can be used by anyone provided that the copyright notice remains intact.
//
// This class provides the logic to simulate Java rectangular arrays, which are jagged
// arrays with inner arrays of the same length.
//----------------------------------------------------------------------------------------
internal static class RectangularArrays
{
internal static int[][] ReturnRectangularIntArray(int Size1, int Size2)
{
int[][] Array = new int[Size1][];
for (int Array1 = 0; Array1 < Size1; Array1++)
{
Array[Array1] = new int[Size2];
}
return Array;
}
}[/code]
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
|
|
|
|
|
Hi All
Do you know if it is possible to split a string in several lines in C#
In C++ I can write
std::cout << "this is a very "
"very very very "
"very very very "
"long string split into 4 lines that will be printed in one";
Do you know if I can do the same in C#?
Thanks
MN
|
|
|
|
|
Yes:
Console.WriteLine( "this is a very " +
"very very very " +
"very very very " +
"long string split into 4 lines that will be printed in one"); Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
|
|
|
|
|
Hi Thanks!
Is there any other way without the + char at the end?
For each + I think that C# due to how the String are will create
in memory a new object that is the result of "String1" + "String2".
I need just some facility so that compiler will recognize that it
must print on the same line.
This was the purpose of my questions even if I didn't make it explicit
|
|
|
|
|
Hi,
the C# compiler understands concatenation of string literals and executes them once, while compiling. It all results in one big string literal before your code actually gets executed, just the way you intended it. You could check with Reflector[^].
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
modified on Friday, February 26, 2010 12:57 PM
|
|
|
|
|
could try this
Console.WriteLine(@"this is a very
very very very
very very very
long string split into 4 lines that will be printed in one")
|
|
|
|
|
Thanks, but I need the string on the same line not on different lines.
When I have to print that I will see the new line I guess.
|
|
|
|
|
manustone wrote: I guess
Read the documentation; perform an experiment; don't guess.Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Does anyone know why when I build a C# class library assembly that the meta file would contain any data? Is there some project setting I need to enable?
My class library has 6 classes, but when I open up the MyLibrary.dll.meta file it just says "No meta data found." This is a problem because then my main project -- about 300 source files and 100,000 lines of code -- wants to rebuild itself every time I make the smallest change to my library. The compiler gives me the message:
Cannot inspect MyLibrary.dll.meta. Assuming significant changes...
So if I change even one line of code in the library project, I have to sit here for several minutes while the main project rebuilds from scratch. What a waste of time!
Has anyone seen this before? How do I get the meta data file to properly populate when I build the library project?
P.S. -- Using Windows 7 64-bit (project set for 32-bit platforms), VS2008 with all service packs applied, and the same thing happens when I try to create a managed C++/CLI library as well. I can't get meta data to generate for any library in any language.
|
|
|
|
|
FYI... It looks like I resolved it by cleaning the solution and rebuilding everything. Now all my .dll.meta data file have metadata in them and I can't reproduce the problem when I make additional updates to the class library. Looks like a Visual Studio glitch.
|
|
|
|
|
Compute is one of the methods of DataTable class. This method computes an expression on the current rows that pass the filter criteria.
Syntax
Object DataTable.Compute(string expression , string filter)
Expression - The expression to compute.
Filter - The filter to limit the rows that evaluate in the expression.
This method's return type is System.Object. So, you have to cast it with appropriate data type.
The following operations can be passed through as expression parameter.
Sum -> Sum
Average -> Avg
Minimum -> Min
Maximum -> Max
Count -> Count
Statistical standard deviation ->StDev
Statistical variance -> Var
http://www.mindfiresolutions.com/DataTable-Compute-Method-628.php[^]Cheers,
Eliza
|
|
|
|
|
Congratulation, you are one of the few who have read the documentation.
Now, do you have an actual question? I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hey - don't knock it. It's the first time I can remember that someone's actually posted the answer to their homework instead of the question... 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
|
|
|
|
|
We don't do homework. Guessing what the question of the homework is, we don't do either.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hi all,
I am working on a Win32 application. We are enhancing it by creating some part of UI in .Net/WPF. Our core code is in C/C++ and some part of UI is in .Net/WPF. And We integrate these modules (C/C++ and .Net) via Managed C++.
Now I have to provide drag drop support. I need to drag some content from .Net UI and dropping it in C++/Win32 UI.
Can anybody help me knowing how to go about it?
Or let me know please how to implement drag drop from outside a .Net application (I mean drag from a .Net application and dropping outside it)
If some sample code or hyper-link can is there, please let me know.
Thanks and Regards
Aseem
|
|
|
|
|
|
Thanks Saksida,
It will really help me.
|
|
|
|
|
I wrote some codes for my usercontrol,but my codes doesn't work properly.I am trying to fill or unfill rectangles on my grid with colors during mouseMove event.When I move mouse from right to left or top to bottom, it works fine,but when I move mouse left to right or bottom to top it doesn't work properly.
I couldn't solve that problem after many efforts.
thank you in advance.
|
|
|
|
|
ahmetkoc wrote: I couldn't solve that problem after many efforts
Neither can we without seeing what you have done. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
This is a little vage. Can you post a sample code of your mouseMove event.
|
|
|
|
|
private void zemin_MouseMove(object sender, MouseEventArgs e)
{
if (!this.ClientRectangle.Contains(e.X, e.Y)) return;
AtkiCozguNo(e.X, e.Y);
if (!tusaBasildi) return;
if (atki == sonAtki & cozgu == sonCozgu) return;
sonAtki = atki;
sonCozgu = cozgu;
renkKontrol(e.X, e.Y);
}
private void renkKontrol(int x, int y)
{
if(bitmapPixel.GetPixel(this, x, y).ToArgb()==this.BackColor.ToArgb())
{
kutuDoldur(Color.Red);
}
if(bitmapPixel.GetPixel(this, x, y).ToArgb()==Color.Red.ToArgb())
{
kutuDoldur(this.BackColor);
}
}
private void kutuDoldur(Color renk)
{
using (Graphics myKutu = Graphics.FromImage(kutuResmi))
{
myKutu.FillRectangle(new SolidBrush(renk),new Rectangle(xKoordinat,yKoordinat,kutuEbadı,kutuEbadı));
}
Invalidate();
}
private void zemin_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(kutuResmi, 0, 0);
}
|
|
|
|
|
First, it is hard to read your code, because it isn't formated (with <pre></pre> tags) and because there are a lot of non english variable names.
I woud love a few screenshot, how it shoud be and how it does happen. Have you thought of adding MouseUp and MouseDown events?
|
|
|
|
|
Hi Saksida,
I have already used MouseUp and MouseDown events to ensure left-mousebutton pressed.
I have screenshot but dont know how to send via forum.
The idea is on mousemove event check the grid cells whether filled or not with color red while left-mousebutton pressed.Cells were checking by GetPixel static method,checking is being done only entering new cell.
private void zemin_MouseMove(object sender, MouseEventArgs e)
{
if (!this.ClientRectangle.Contains(e.X, e.Y)) return;
AtkiCozguNo(e.X, e.Y);
if (!tusaBasildi) return;
if (atki == sonAtki & cozgu == sonCozgu) return;
sonAtki = atki;
sonCozgu = cozgu;
renkKontrol(e.X, e.Y);
}
private void renkKontrol(int x, int y)
{
if(bitmapPixel.GetPixel(this, x, y).ToArgb()==this.BackColor.ToArgb())
{
kutuDoldur(Color.Red);
}
if(bitmapPixel.GetPixel(this, x, y).ToArgb()==Color.Red.ToArgb())
{
kutuDoldur(this.BackColor);
}
}
private void kutuDoldur(Color renk)
{
using (Graphics myKutu = Graphics.FromImage(kutuResmi))
{
myKutu.FillRectangle(new SolidBrush(renk),new Rectangle(xKoordinat,yKoordinat,kutuEbadı,kutuEbadı));
}
Invalidate();
}
private void zemin_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(kutuResmi, 0, 0);
}
|
|
|
|
|
I do not see any problem with it. Nor do I know what kind of confusion it is, xKoordinat and yKoordinat properly calculated?. Also for screen shot, you could upload to www.photobucket.com and put here a link.
PS: Sorry for not answering your email. I was in a hurry
|
|
|
|
|