473,699 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET -. C# signatures different for XML Attributes

I notice when moving from VB.NET -> C# that the overloads are different
for

<XMLRoot(.... ) >
[XMLRoot(....) ]

<XMLElement(... .) >
[XMLElement( ....) ]

but in notice the following seems to compile in C#
[XmlRoot(Element Name="message", Namespace="http ://myurl")]

even though this is option is not shown Intellisense.

i imagine this related to C# not supporting optional parameters.

But is it ok to proceed as above?

Dickster

Nov 12 '05 #1
2 2816
also tell me this:

Why to i have to capatalise the first letter in ElementName & Type when
the documentation says:
XmlElementAttri bute(String elementName,Sys tem.Type type)

This doesnt compile
[XmlElementAttri bute(elementNam e="dickster",ty pe =
typeof(dickster sClass))]

But this does compile
[XmlElementAttri bute(ElementNam e="dickster",Ty pe =
typeof(dickster sClass))]

Nov 12 '05 #2
"dickster" <gd***@kerrhend erson.com> wrote in message news:11******** *************@o 13g2000cwo.goog legroups.com...
Why to i have to capatalise the first letter in ElementName & Type when : : This doesnt compile
[XmlElementAttri bute(elementNam e="dickster",ty pe =
typeof(dickster sClass))]

But this does compile
[XmlElementAttri bute(ElementNam e="dickster",Ty pe =
typeof(dickster sClass))]


There is a fundamental difference between [XmlElement( "Joe")] and
[XmlElement( ElementName = "Joe")].

The first case is creating the XmlElementAttri bute by calling the constructor
that takes a single string argument. As you've mentioned, the name of that
parameter is elementName, but it doesn't really -- the fact is it's a constructor
that takes one string and that's all the runtime cares about. The sequence of
arguments matters, because it must match the formal parameters list of the
constructor.

The second case creates the XmlElementAttri bute by calling the default
constructor which takes no arguments. After it constructs the XmlElement-
Attribute, it then goes through and sets properties on it. The property name
is ElementName, proper case and case sensitive.

[XmlElement( ElementName = "Joe", Type = typeof( Restauranteur))], and
[XmlElement( Type = typeof( Restauranteur), ElementName = "Joe")]

are the same except for the order in which the properties get assigned. Thus,
it's not a magical way of passing parameters to a constructor where the run-
time magically figures out what you meant to do, but a standard feature that
is applicable by necessity.

Think of the requirements for XmlElementAttri bute, and runtime attributes in
general, if there needed to be overloaded constructors for every possible
combination of properties developers might want to set? Without them, it
would be terribly inconvenient to set some of the less-frequently used
properties like IsNullable and Form (GetCustomAttri butes( ) at run-time,
anyone?)
Derek Harmon
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2897
by: Adie | last post by:
Hi, I wonder if anyone might lend me a brain. I have a stock database to build that covers over 1000 products, which might be said to exist in around 50 product families. Obviously, just to be awkward all the types of stock will have different attributes. So one product might be a tube with inside/outside diameter and length and another a T shaped cable joint. All I can come up with is a separate table for each stock type family
16
9536
by: Bob Rock | last post by:
Hello, when serializing an array of elements of a class Classname using XmlSerializer.Serialize() I get an XML like the following: <?xml version="1.0"> <ArrayOfClassname> ....... ....... </ArrayOfClassname>
4
4855
by: Burghew | last post by:
Hi all, I am trying to design a database in access 2002. I have multiple category of items such as computers which may include laptop, server, pc...all of these items have different attributes, similarly printers with sub categories deskjet, laser, line, etc also have diff attributes...like that I have multiple items in my inventory (around 30 items) all with different attributes. After going through normalisation I guess I need to have...
2
1508
by: Burghew | last post by:
Hi all, Kindly help me out on this one. I am having a computer shop and we have many IT related equipments nearly 30 categories which comprises of Servers, Laptops, PC's, Printers, routers, switches, monitors, Software etc... Now each of the aboved mentioned category have different attributes such as Servers may have different configuration like raid, SCSI Hdd, etc, Laptops may have different attributes from that of PC's, similarly...
6
11556
by: Matt Frame | last post by:
I have a client that has asked us to get a digital signature certificate and start digitally signing all files we pass between each other. I have heard of the subject and know about the certs but I have no idea how to do something like this with VB.Net. Has anyone done something like this or know where I can find out information how to perform the process of signing a document when sending it then checking one on receipt? Your help is...
1
2899
by: karflips33 | last post by:
Is it possible to automate the signing of Word 2003 docs with Digital Signatures? My problem with the code approach using ActiveDocument.Signatures.Add
4
2361
by: jianyi | last post by:
Hi, I am working on an xml project, and I am trying to understand something. if the author needs to sign one xml file, then his manager will counter-sign, and a third witness will sign, can this be achieved in Java xmldsig package? (or any other package?)
6
2148
by: tshad | last post by:
Is there a way to set one item in a dropdown list to a different color? I have a case where I might have 15 items and one is a default and would like to set the default as green where all the rest are black. I looked at the examples from http://www.c-sharpcorner.com/Code/2003/July/ColorFullDropDown.asp and http://www.c-sharpcorner.com/Code/2003/July/DropDownListBox.asp but I can't seem to get it to work.
13
4883
by: anil.rita | last post by:
When the user chooses an AV file to play, based upon the type of file, I want to use the default installed media player to play it. I am wondering if this is a good way - any alternatives, suggestions or improvements? if( wmv file) document.write("<OBJECT id=Player classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 height="354" width="479">
0
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7750
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.