|
Hi,
do C# exists an function like memset in C?
I want fill initial value for an matrix, has another way to fill value for matrix except use 2 loop?
Thanks.
H.Dung
|
|
|
|
|
|
|
awesome, thanks...
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Thank you
Kannan
|
|
|
|
|
I don't think a book on "Data Structures and Algorithms" should start with assigning nifty constants to all kinds of operations, and then forego and analyze the "running time" of several algorithms. This sets the wrong priorities (and has some distinct errors in the precense of a garbage collector)
The rest seems to be well selected, though. xome important graphics unreadable, but who cares if it's free?
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
peterchen wrote:
I don't think a book on "Data Structures and Algorithms" should start with assigning nifty constants to all kinds of operations, and then forego and analyze the "running time" of several algorithms.
I havent seen any other books do this and that why I find it so fasinating. Futher down it actually implements all the algorhytms. And the book is also available for Java and C++.
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
Hello
I have 2 lines (3 points). I pass these 3 points to Graphics.DrawCurve() function, which in turn draws a smooth curve on some specified graphics surface for me. The problem is that I need the curve line's equation. Maybe at last I have to write such a function myself. The existence of such a function makes my work easier. is there any way for me?
Don't forget, that's " Persian Gulf " not Arabian gulf!
|
|
|
|
|
It's a so called canonical spline.
Basically they are cubic splines where each segment is determined by the bonding points and the two "surrounding" points.
Petzold has a short derivation of it, with sample and "play around" program (i.e. he's doing the spline himself)
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
unfortunately I don't have that book.
Have you got the "play around"'s source code that you mententioned?
Don't forget, that's " Persian Gulf " not Arabian gulf!
|
|
|
|
|
Hi
1. Why cant you have a "params" parameter for the constructor of an attribute?
2. Why do you have to provide a constructor in an inherited abstract class where the base class does not have a default constructor?
Any input welcome
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
leppie wrote:
Why cant you have a "params" parameter for the constructor of an attribute?
This compiled for me:
public class Foo : System.Attribute
{
public int [] bar;
public Foo(params int [] a)
{
bar = a;
}
} leppie wrote:
Why do you have to provide a constructor in an inherited abstract class where the base class does not have a default constructor?
I assume you mean the abstract class has a constructor that takes parameters rather than no constructor at all.
With C# if you don't supply a constructor, a default constructor is supplied for you. Similarly if you don't explicitly call the base class's constructor it attempts to call the default constructor for you.
In the case where the base class has only non-default constructors the compiler still tries to call one from the auto-generated default constructor for the child class, causing an error saying that method "Foo" has no overload that takes 0 arguments.
For example:
public class Foo
{
public int bar;
public Foo(int a)
{
bar = a;
}
}
public class What
{
} Results in the said error message.
Whether the base class is abstract doesn't play a part in this at all
All testing on .NET v1.1
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
James T. Johnson wrote:
This compiled for me:
Did you try use it? Sorry forgot to mention it does compile, but its not usable.
James T. Johnson wrote:
I assume you mean the abstract class has a constructor that takes parameters rather than no constructor at all.
This is what I mean:
class Foo
{
public Foo(string blah){...}
}
abstract class Poo : Foo
{
}
An abstract class may not be constructed, so why do you need to provide a constructor?
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
leppie wrote:
An abstract class may not be constructed, so why do you need to provide a constructor?
It really isn't required, in fact this compiled fine for me (and worked) when I commented out the constructor:
abstract class CreditCard
{
public static bool Validate(string CreditCardNumber)
{
int sum = 0;
for(int i = 0; i < CreditCardNumber.Length; i++)
{
if((int)CreditCardNumber[i]%2 != 0)
{
if((int)CreditCardNumber[i] * 2 > 9)
sum += ((int)CreditCardNumber[i] * 2) - 9;
else
sum += (int)CreditCardNumber[i] * 2;
}
else
{
if((int)CreditCardNumber[i] != 0)
sum += (int)CreditCardNumber[i];
}
}
return(Convert.ToBoolean(sum%10));
}
}
-Nick Parker
|
|
|
|
|
|
leppie wrote:
But alas no base class
You can do something like this, if this is what you mean:
abstract class Poo
{
...
}
public class Foo : Poo
{
Foo(){}
...
}
Foo f = new Foo();
-Nick Parker
|
|
|
|
|
leppie wrote:
Did you try use it? Sorry forgot to mention it does compile, but its not usable.
That's just it: it does work for us (otherwise our application wouldn't work right). How are you using the attribute?
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
|
1.0.5000.0 (.NET 1.0 SP2)
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
leppie wrote:
An abstract class may not be constructed, so why do you need to provide a constructor?
If you don't provide one at all (and alter the C# compiler to not provide one for you) you can't inherit from it to make use of the abstract class.
We can infer that because combining abstract with sealed results in an error that the C# desigers want the abstract keyword to imply that you want the class to be inherited from at some point.
It is perfectly legal to have a private constructor on an abstract class, which if all constructors are private then the class can't be inherited from.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
leppie wrote:
1. Why cant you have a "params" parameter for the constructor of an attribute?
You can. I've been doing it in our app for over a year (soon after the 1.0 release was released; never tried it before that). The following should work:
public class MyAttributeAttribute : Attribute
{
private string[] parms;
public MyAttributeAttribute(params string[] parms)
{
this.parms = parms;
}
}
It works for me. Perhaps a code snippet would help.
leppie wrote:
2. Why do you have to provide a constructor in an inherited abstract class where the base class does not have a default constructor?
Just to clarify, is the abstract class being inherited, or does it inherit from another class? If the latter is the case, is the base class also abstract?
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
|
|
|
Nope, that's how we do it at work, using String s and everything. The code snippet I gave before is the syntax I used. Is this in .NET 1.0 or 1.1, BTW?
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|