|
My last and first posts were mature but you obviously didn't see it that way.
I answered you're question, I'm sorry if I miss understood it, but in that case you should have explained it more clearly.
You asked in all the wrong forums and from what I can tell when you did ask in the right forum you got an answer.
You have to undertstand that people just sign up to this site and ask people to do their homework/projects for them all the time because they are too lazy or simply don't know how, normally they cross post their questions several times which really riles people up. You fell into this stereotype and were rude which is why you got more hostilities.
Do you see why people here are blunt now?
(I don't mean any offence)
ps.
Ha lee wrote: crab
Where did you get 'crab' from?
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
I do posted into several forums and perhaps in the wrong ones too. But for your information, I got better and more useful replies from other forums than this one. Here too, people have been helpful except the fact that I cross posted my question several times, which was by mistake and I realized that later. Yes it is my assignment and you are again rude when you say that people are blunt and I fell in this category. But I had to post my assignment here because I don't have any idea about cryptography and I am new in that field . But as far as programming is concerned , I don't have any problem. That's why I just wanted a clue which algo may work or what approach should I use.
And for your info , I got very positive replies from everywhere and every person except when I had to confront an immature person like you who can only make useless debates in order to show the world that you are the only genius in the world and all other are just stupid. I have never ever been lazy for my assignments. this was my first ever post here as i told you I don't know about cryptography and just know about programming. I didn't get any hostility only you are a strange kind of person , who made me to think more about the offensive talk rather than my assignment. In the end, I would say 'can you tell me how can I get rid of you?'. Because I have some other stuff to do too . I am not free like you to quarrel with different persons on the web. I had heard that programmers don't even get time to eat . But I dunno who are you really. So if you have got nothing to do, at least stop arguing here. Because all the world is not like you. Find a free person like you who can also argue in this way and then start arguing with him. i am not here to entertain you when you have nothing to do.
Stop here.
|
|
|
|
|
Ha lee wrote: you are again rude when you say that people are blunt and I fell in this category
You missed my point entirely. I meant the people who have to put up with people who ask to be spoon fed. I didn't imply that it was you.
I wasn't being rude, immature or anything then. I was explaining why.
I tried to help you, but you shot me down and still haven't explained why, I am sorry for misunderstanding.
Ha lee wrote: But for your information, I got better and more useful replies from other forums than this one.
That is because this forum is the wrong one for this topic as I said in my first post.
The answers you got were in the C and Algorithm forums, which is where they were meant to be asked, were the ones which understood your needs best.
Ha lee wrote: at least stop arguing here.
I have stopped arguing. I can assure you that what I have said in my last couple of posts is sincere, you just haven't interperated it that way unfortunately.
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
Ha lee wrote: there's only one person in the room with some problem who sends me messages with different names, sometimes with crab, fly etc.
Obviously, you're too clueless to realize that Fly904 and I are different people. As for how well you're received here, why didn't you look at your message list in your profile and see how many people voted 1 on your messages. Admittedly, a few of those are mine but I'm hardly alone. If you show you've made an attempt to research and understand your problem and ask specific questions, you're likely to get an answer here. But just coming in and cross posting your first question and basically say I've done nothing so just spoon feed me so I can quickly do my homework, it's generally going to get you anything but hostility.
"Republicans are the party that says government doesn't work and then they get elected and prove it." -- P.J. O'Rourke I'm a proud denizen of the Real Soapbox[ ^] ACCEPT NO SUBSTITUTES!!!
|
|
|
|
|
If fly and you are 2 different persons then why are you both writing me the same things??? Only you and him have really got some problem but all others don't have any problem with me . If many people have voted 1 for my comments , you also got the same . Don't make it your misconception. You are of worst standard for me.
And go to hell, I didn't come to you to beg for anything. If you want to answer well and good, I would be obliged as this forum is to help others but if you don't want to help me, I don't care . But at least stop being rude to others and don't stuff your head in the things that you don't understand because that will make you frustrated for your low knowledge and you would be nothing but only rude to the people. Understand?????
|
|
|
|
|
And moreover, if you think I have been rude. I really apologize for that as I am a responsible and a mature person.
|
|
|
|
|
I have a custom property that has two string values and an int value. I need to display them in a PropertyGrid so that the property's UITypeEditor edits any of the three properties within that type. An example would be the "Font" type in a PropertyGrid. The name, size, unit, bold, etc. is part of the editor for that property type. Is PropertyDescriptor what I need?
Thanks,
Mark
|
|
|
|
|
Try [BrowsableAttribute(true)] above your property description
|
|
|
|
|
I think you misunderstood my question. I need to add an expandable property like the Font property has when displayed in a PropertyGrid.
MyProperty Category
+ MyProperty my property's value string
Size size value
color color value
name name value
etc....,
How is this done?
Thanks,
Mark
|
|
|
|
|
I think you looking for TypeConverterAttribute and ExpandableObjectConverter.
The following link shows how to do it.
<a href="http://msdn.microsoft.com/en-us/library/aa302326.aspx">
<a href="http://msdn.microsoft.com/en-us/library/ayybcxe5.aspx">
|
|
|
|
|
public abstract class Base
{
public int GetInt()
{
return 1;
}
}
public abstract class AbstractChild : Base
{
public abstract int GetInt();
}
public class Child : AbstractChild
{
public override int GetInt()
{
return 2;
}
}
I want all implementers of AbstractChild to implement GetInt method. So, I decide to make the method abstract even though it's not originally abstract in the Base class. Then I implement it in the Child class. But when I execute the following code, it surprisingly returns 1:
Base b = new Child();
Console.Out.WriteLine(b.GetInt());
Since b is of type Child, I would normally expect the overridden method in Child class to be called. Why is the method in base class being called? Am I misunderstanding something?
|
|
|
|
|
Why do you need to make GetInt abstract in AbstractChild ? Why not make it abstract in Base ?
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,
If you view the compiler warnings you should see what's wrong.
'AbstractChild.Child.GetInt()' hides inherited member
'AbstractChild.AbstractChild.GetInt()'.
To make the current member override that implementation,
add the override keyword. Otherwise add the new keyword.
Alan.
|
|
|
|
|
Hi
Adding new keyword does not solve the problem. It still returns 1
|
|
|
|
|
Hi,
An abstract method must be implemented using the override modifier.
public abstract class Base {
public int GetInt() {
return 1;
}
}
public abstract class AbstractChild : Base {
public new abstract int GetInt();
}
public class Child : AbstractChild {
public override int GetInt() {
return 2;
}
}
When first encountered these concepts are not easy but if you review the information on modifiers in the c# reference and then write some code to test your understanding you'll soon be there.
Alan.
|
|
|
|
|
Do you know why the following code is returning 1 while I have completely replaced the base class method with new operator as you suggested?
Base b = new Child();
Console.Out.WriteLine(b.GetInt());
|
|
|
|
|
Hi,
When you redefine a method with the new modifier it is no longer known to the parent class. The confusing part is that the original method still exists in Base and this is called when you assign the AbstractChild instance into a Base type variable.
If the code is altered (again) we can achieve what I think you originally wanted.
1) declare public virtual int GetInt() in Base
to ensure that the method can be overridden.
2) public override abstract int GetInt() in AbstractChild
This overrides the base class method with an abstract method
3) public override int GetInt() in Child
as required by the abstract modifier in AbstractChild.
Putting all of that together we have
public abstract class Base {
public virtual int GetInt() {
return 1;
}
}
public abstract class AbstractChild : Base {
public override abstract int GetInt();
}
public class Child : AbstractChild {
public override int GetInt() {
return 2;
}
}
class Program {
static void Main(string[] args) {
Base c = new Child();
Console.WriteLine(c.GetInt());
Console.ReadLine();
}
}
The use of the override modifier throughout ensures that the most derived method is always accessible.
Hope you are following the logic, we are both learning here!
Alan.
|
|
|
|
|
Thank you very much for your response Alan! It's working
I didn't know that a method with override modifier can have no body. But with help of override abstract, it can. great to know.
The original code I posted was translated from a java code from Head First Design Patterns book (chapter 3, Decorator Pattern).
Do you know java? It seems that the original code I posted will return 2 written in Java.
|
|
|
|
|
Maysam Mahfouzi wrote: I didn't know that a method with override modifier can have no body.
Actually I didn't either and was a bit surprised too.
I'm not very familiar with java, it's one of my read-only languages, but in contrast to c# it probably has a more relaxed syntax. c# tends to make very few assumptions and as a consequence requires that intentions are stated explicitly.
Alan.
|
|
|
|
|
Hi,
I'm new to the world of .Net and C#. I need some help with serialization:
I'm trying to serialize an object to an XML file, this object has a nested class which I also want to serialize:
[Serializable]
public class NewOrder
{
public NewOrder()
{
}
~NewOrder()
{
}
private string accountGroupfield;
private string accountNumberfield;
public string AccountGroup
{
get
{
return accountGroupfield;
}
set
{
accountGroupfield = value;
}
}
public string AccountNumber
{
get
{
return accountNumberfield;
}
set
{
accountNumberfield = value;
}
}
[Serializable]
public class CardDetail
{
private string cardFirstNamefield;
private string cardLastNamefield;
private string cardNumberfield;
public string CardFirstName
{
get
{
return cardFirstNamefield;
}
set
{
cardFirstNamefield = value;
}
}
public string CardLastName
{
get
{
return cardLastNamefield;
}
set
{
cardLastNamefield = value;
}
}
public string CardNumber
{
get
{
return cardNumberfield;
}
set
{
cardNumberfield = value;
}
}
}
I have a function to serialize the object but all I get in the Xml file is:
<?xml version="1.0"?>
<NewOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<AccountGroup>100</AccountGroup>
<AccountNumber>66302</AccountNumber>
</NewOrder>
I've been searching around the internet for days now, but I still havent managed to get the nested class output as a nested element within the XML.
Apologies for rambling, the output to the XML I'm looking for is as follows:
<?xml version="1.0"?>
<NewOrder xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<AccountGroup>100</AccountGroup>
<AccountNumber>66302</AccountNumber>
<CardDetail>
<CardFirstName>George</CardFirstName>
<CardSurname>Balden</CardSurname>
<CardNumber>6123 2222 4444 6666</CardNumber>
</CardDetail>
</NewOrder>
|
|
|
|
|
Well as far as I can see, you never declare an instance of CardDetail . Serialization only serializes instances of objects, not declarations of objects.
BTW, unless there is something in the part of your code that you haven't posted, I see no reason for CardDetail to be a nested class.
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.”
|
|
|
|
|
Could you provide some sample code of how i do that, and where i put the code?
would it be similar to:
public CardDetail MyCardDetail;
before i declare the class? Thanks in advance!
George
|
|
|
|
|
Yes but you will need to instantiate it and give its properties some values.
Add the declaration as you have suggested (I would put it with the other two field declarations). Also, strictly speaking you should make it private, then add a public property for access from outside the class.
Then modify your constructor for NewOrder, something like:
public NewOrder()
{
MyCardDetail = new CardDetail();
MyCardDetail.CardFirstName = "Horace";
MyCardDetail.CardLastName = "Horsecollar";
MyCardDetail.CardNumber = "1ABC23";
}
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 Henry, thanks for your help,
I updated the project with your comments but now I'm getting a HTTP 500 error when i Invoke the web service, the full code listing is below:
order.aspx.cs
using System;
using System.IO;
using System.Xml.Serialization;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using ExampleforCodeProject;
namespace ExampleforCodeProject
{
[WebService(Namespace = "http://MyXmlTest/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Order : System.Web.Services.WebService
{
[WebMethod]
public NewOrder SerialiseOrder()
{
NewOrder order1 = new NewOrder();
order1.AccountGroup = "11";
order1.AccountNumber = "878";
order1.Card.CardFirstName = "George";
order1.Card.CardLastName = "Balden";
order1.Card.CardNumber = "872947924793274";
Stream stream = File.Open("C:\\test\\NewSoap.xml", FileMode.Create);
XmlSerializer sf = new XmlSerializer(typeof(NewOrder));
sf.Serialize(stream, order1);
stream.Close();
return order1;
}
}
}
and the Order class (NewOrder.cs):
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ExampleforCodeProject;
namespace ExampleforCodeProject
{
[Serializable]
public class NewOrder
{
public NewOrder() { }
~NewOrder() { }
private string accountGroupfield;
private string accountNumberfield;
public string AccountGroup
{
get
{
return accountGroupfield;
}
set
{
accountGroupfield = value;
}
}
public string AccountNumber
{
get
{
return accountNumberfield;
}
set
{
accountNumberfield = value;
}
}
public CardDetail Card;
[Serializable]
public class CardDetail
{
private string cardFirstNamefield;
private string cardLastNamefield;
private string cardNumberfield;
public string CardFirstName
{
get
{
return cardFirstNamefield;
}
set
{
cardFirstNamefield = value;
}
}
public string CardLastName
{
get
{
return cardLastNamefield;
}
set
{
cardLastNamefield = value;
}
}
public string CardNumber
{
get
{
return cardNumberfield;
}
set
{
cardNumberfield = value;
}
}
}
}
}
Thanks again for all the help!
|
|
|
|
|
I do not see a Card = new CardDetail() anywhere, you must create an instance before you can use it. I would suggest that you put it in the Constructor for NewOrder since each NewOrder currently requires CardDetail. Later you might want to switch to Lazy Initialization (google it for details).
Although it is difficult to see why that would give an HTTP Error, it is necessary, so try it anyway.
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.”
|
|
|
|