|
Hey guys,
I have been toying around with the idea of writing a website creation program geared to novice computer users. I have googled it and I can't find anything helpful in regards to how to structure the program or writing code generation. Can anybody point me in the right direction?
may your code be error free
|
|
|
|
|
There are 3 parts:
1. Input
2. Processing
3. Output
Seeing you have some form of input and you desire some form of output, the implement step 2. 90% of applications use this 'data transformation'. There is no magic involved.
|
|
|
|
|
Hi,
This is just off the top of my head as I haven't done any web work for years, but depending on exactly how much functionality you wish to offer and what code you wish to generate, you should look at .NET CodeDOM for code generation and the use of XSLT with XML. XSLT can convert XML to HTML or XHTML markup, but it can also be used to generate C#, javascript or any other language from XML. If you got the users to make selections via your UI then stored these as XML you could easily generate code thus. I'm sorry not to provide more detail, but I think this is at least the right direction.
Regards,
Toby
|
|
|
|
|
Thanks a million Toby for the heads up. That's the most info i've got so far. I'll definitly take a look at it and if you have anymore info, I'd be happy to hear it!
Thanks again,
Richard
may your code be error free
|
|
|
|
|
how can I convert a char arrayto a string?
i used method ToString() but it dosn'twork .
|
|
|
|
|
One of the constructors for a string takes a char[].
|
|
|
|
|
you can try:
string s = new string(mycharArray);
|
|
|
|
|
For generic purpose type converting there's a static class "Convert". There you have a "ToString([param])" method
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
I think the best way to do that is to use a generic list
List<char> chars = new List<char>();
chars.Add('t');
Console.WriteLine(chars[0].ToString());
Lester
http://www.lestersconyers.com
|
|
|
|
|
lsconyer wrote: the best way
The best way to fail a code review maybe!
|
|
|
|
|
That's a bad idea, lester. First of all, it only returns the first character as a string, not the whole character array. Secondly, adding the chars to a list does nothing to help converting the whole thing to a string.
|
|
|
|
|
Did you look at the earlier replies at all ?
your "best way" is plain wrong, it does not address the problem, it needs at least .NET 2.0,
it creates more than one object, and it is in no way better than a simple string constructor.
Life is study.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
My, my, my. I didn't know programmers could be so sassy. Excuse me experts. I guess I didn't understand the problem. Please forgive me.
Lester
http://www.lestersconyers.com
|
|
|
|
|
lsconyer wrote: Please forgive me
No problem.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
We don't mean to be sassy, just wanted to correct a wrong answer. No harm meant.
|
|
|
|
|
string str = new string(char[] value);
Toby Russell
|
|
|
|
|
Dear all,
i would like to know is it possible to use function with optional parameter or is there any better way of doing so.
thnk you
imaran khan
|
|
|
|
|
There are no "default" parameters like there are in C++.
However, you can achieve the same thing with a simple overload.
public void myFunction(int requiredArg){
myFunction(requiredArg, false);
}
public void myFunction(int requiredArg, bool optionalArg){
}
|
|
|
|
|
thank for reply
Actually i have one to fifteen parameter and fuction must take one parameter and rest depending on user choice program will pass.
how to do that
please help
thanks
imaran khan
|
|
|
|
|
Could you explain it a bit more please?
You could cast all the parameters to an object[] and then cast them back inside of the function, giving default values to the ones that the user didn't specify.
|
|
|
|
|
thnks for reply.
let me explaine the scenario. there is 15 field say suppose
customer , category ,subcategory etc ..
User select category or subcategory or customer or any thing
depending on selection ,value from corresponding master is populated. now i select values from dropdownlistbox and pass to fuction.
Now my problem is user may select only customer or category or subcategory. may select combination or all.
please guide.
thanks
imran khan
|
|
|
|
|
Might be worth using Nullable Types and simply leaving all non selected values as Null. Then check for the values that aren't null and proceed accordingly. That way you keep your function footprint and it's strongly typed.
Alternatively, you could use an argument object / struct containing the parameters so you only have to change your object, rather than breaking the function footrpint with each change, just watch for mapping breaks.
T
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
If the parameters are of the same type, you can use the params keyword:
public void SomeMethod(string firstParameter, params int[] theOtherParameters)
This method can be called with any number of parameters following the first parameter:
SomeMethod("count", 1, 2, 3);<br />
SomeMethod("answer", 42);
If you want an upper limit, you have to check the lenght of the params array in the method.
---
single minded; short sighted; long gone;
|
|
|
|
|
As Guffa mentioned, if the parameters are all of the same type you can use the params keyword. (You could also use params object[], but you loose the type safety.)
Another option is to use either an enum to specify related groups of options or create a class that holds the arguments (parameters) and pass that class. The enum is similar to the
String.Compare(String, String, StringComparison)[^] method while the args class is how the .NET event handling does things (through the EventArgs[^](or derived) class.)
|
|
|
|
|
hi there,
I'm currently building a webservice and I've got three questions: is there anything special i need to know about the returned xml? right now, I just return an object (for expample an instance of my Vehicle class) from the WebMethod and this looks fine to me.
The second question is, if I use the automated xml serialization with a class which is derived from a base class I defined (e.g. I've got a Car class which derives from the Vehicle class), the properties of the baseclass are not serialized. Properties of the derived class look fine. Why is that?
Last but not least: What is the correct way to return an error from a WebMethod if, for example the expected parameters are invalid or an exception occured.
thanks a lot!
/matthias
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
|
|
|
|