|
S. Senthil Kumar wrote: so stack space will be reserved right away.
I doubt. AFAIK, it depends on the context where the struct variable is used. If it is declared with a instance field, I guess it will be kept in the heap along with the instance. I am not sure though. This[^] is worth reading.
|
|
|
|
|
Good point, do you have any ways to test or prove whether memory is allocated or not for value type variables used as a member field for a reference type?
regards,
George
|
|
|
|
|
Which is why I said "In both cases, stack space will be reserved for holding the local variable.
|
|
|
|
|
Thanks Senthil,
Question answered.
regards,
George
|
|
|
|
|
George_George wrote: And even if we provide a customized one, the default parameter-less one still exists.
NO.
class Program
{
static void Main(string[] args)
{
Foo foo = new Foo();
}
}
class Foo
{
public Foo(int param)
{
}
} The above code won't compile. When you provide a constructor, comoiler won't generate a default one.
|
|
|
|
|
Thanks ForumExpertOnLine!
1.
Good to learn from you value type and reference type treat this scenario differently -- whether or not the default constructor exists if we provide a customized constructor -- for value type, it exists and for reference type it does not exists. Right?
2.
Any comments to?
http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2598697[^]
regards,
George
|
|
|
|
|
George_George wrote: for value type, it exists and for reference type it does not exists. Right?
Yes. For structs, default parameterless constructor is created automatically. You can't write a parameterless constructor for a struct.
|
|
|
|
|
Thanks ForumExpertOnLine,
Question answered.
regards,
George
|
|
|
|
|
Hi,
I have a XML document (that I've got from an InfoPath form) and it has its namespaces.I'd like to deserialize this XML document into a type and send it to a WebService.The type has been generated when I referenced the WebService in my project.
When I try to deserialize the XML document I get a "xmlns was not expected" error thrown by XmlSerializer.
What should I do to either remove namespaces from the XML document or introduce them to XmlSerailizer so It can recognize QNames?
Regards
|
|
|
|
|
I want to make sure I understand...
You have some XML from an InfoPath form and want to pass that to a Web Service. The Web Service takes a parameter (likely a class) that looks something like your XML, but when you try to cast your XML into the Web Service's type by attempting to deserialize your XML you get the error.
If this is the case, you are getting the error because the InfoPath type is different from the type that the Web Service is expecting.
The easiest way to get this to work is to compare what the web service expects with the XML from infopath. If only the namespace, or namespace prefix, or both is/are different, you could take the quick route and use basic string manipulation to remove/edit as necessary.
Manipulating XML strings directly is not recommended in most cases, but it does make sense in some since some transformations are really that simple.
The correct way of accomplishing this is to transform the XML InfoPath into the serialized version of the type that the web service expects and then send deserialze it into the WS's type. You transform from one type into another using XSL and a bit of code to do the transformation.
The problems with transforming using XSL include:
- You need to know at least some XSL
- Storage of the XSL
- Changes in either the input or output require changes to the XSL
If you don't want to go with either approach, you do have one more option: extract the values you need from the InfoPath XML and copy the values into the type that the Web Service uses - sort of a manual transformation. You cold extract values from the InfoPath XML using XPath queries or just grab them using regular expressions or brute force string matches.
So, you have a few options. Your choice depends on how comfortable you are with the underlying approaches and whether you'll end up maintaining whatever you choose
Erik Westermann - wWorkflow.net - Consulting Services
SOA * ESB * BPI ...and lots of other cool TLAs related to integration and architecture.
|
|
|
|
|
Thank you very much for you kind and helpful reply.
|
|
|
|
|
Hi ALL,
I need only Time format in Textbox..So please..How to do..
Regards
Somasundaram G
|
|
|
|
|
Hello
Give me the complete detail? If u wnat to put time in a text box then simply change the format using DateTime class and then assigned to text box. Simple.
Syed Shahid Hussain
|
|
|
|
|
I need Time Format like this 06:30:40 in TextBox.So pls..
I want to join in the website
|
|
|
|
|
if you put in the textbox..
here's the code...
textBox1.Text = DateTime.Now.ToLongTimeString();
if you want the seconds to move like a digital clock use timer with it..
|
|
|
|
|
System.DateTime dTime = new System.DateTime(2001, 5, 16, 3, 2, 15);
// If the current culture is "en-US",
// longDateString gets "Wednesday, May 16, 2001"
string longDateString = dTime.ToLongDateString();
// If the current culture is "en-US",
// longTimeString gets "3:02:15 AM"
string longTimeString = dTime.ToLongTimeString();
or u can use DateTime.ToShortTimeString() method
|
|
|
|
|
|
hello... could someone give me the necessary codes for this project..
I really need it.
the system must automatically receive fax data from 3 modem simultaneously and allows the user to save, edit, delete and print those faxes,
also those faxes when receive must be in image form..
thanx...
ginji amano
|
|
|
|
|
I have 3 tables students, courses and courses_tables. The thing I don't understand is that do i need to have student_id as a Foreign key in courses table. Secondly, what kind of key i need to define in the courses_taken table. I am thinking of a composite primary key of std_id and course_id inside the courses_taken table but that doesn't make sense for me too. The reason being is that shouldn't student be allowed to take the same course again. What do you think that how many primary keys i need to have in these 3 tables and Foreign keys.
Thanks
CREATE TABLE STUDENTS
(
std_id int not null identity,
std_name varchar(50) not null,
std_program varchar(20) not null,
std_email varchar(50) not null unique,
constraint std_id_pk PRIMARY KEY(std_id)
)
CREATE TABLE COURSES
(
course_id int not null identity,
course_name varchar(50) not null unique,
std_id_fk int references STUDENTSRK(std_id)
constraint course_id_pk primary key(course_id)
)
CREATE TABLE COURSES_TAKEN
(
std_id int not null,
course_id int not null,
section_id varchar(10) not null,
semester varchar(20) not null,
mark int not null,
)
|
|
|
|
|
According to my knowledge you don't need the std_id_fk in the Courses Table as a foreign key.
coz that doesn't makes any sense...you can have only 10 courses, but if u keep the std_id as foreign key, you will have same course names with different course id's, which is redundant.
you can just create a composite primary key of std_id and course_id, that's all.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
I think the primary keys should be unique ids, not combinations of ids. I think the important thing is foreign keys for refernetial integrity I also think you should have asked in the SQL forum.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
That's what i thought too that i don't need std_id_fk foreign key in courses table but what about the Courses_Taken table, if i make it a composite key std_id and course_id then a student cannot take the same course again am i right. is there any relation of courses_taken table with any other table or am just overloading my brain. Thanks
|
|
|
|
|
yes, a student cannot take the same course again...and that is correct, a student shud be allowed to take a course only once.
Y would u want him to take the same course again?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Y wouldn't you what if a student wants to upgrade his marks by re-taking the same course again.
|
|
|
|
|
But then the term wud be changed, rite?
he cannot take the same subject twice in the same term.
So you shud also maintian the term for which the student has selected the subjects.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|