|
Hi Guffa,
Guffa wrote: The 0x80 literal is an int value.
It's a shame C# has a penchant for the Int conversion, even when I specify otherwise. For example, the following:
Byte b = 0x80;
b = ~b; results in a Compiler Error:Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?) Humorous... When I attempt to cast, it complains also. The problems would go away if the compiler would listen to the human operator and simply compliment the Byte value b .
Jeff
|
|
|
|
|
Hi All,
I believe this is the cause of my grief. Microsoft documentation states:
The ~ operator performs a bitwise complement operation on its operand, which has the effect of reversing each bit. [1] This is very misleading: it does not compliment an operand - it compliments an Int . The programmer is left to clean up the mess created by the compiler.
Jeff
[1] ~ Operator (C# Reference)[^]
|
|
|
|
|
Hi all,
What is a better design in visual studio.
To create separate datasets for each database table or
one dataset with all tables on the dataset.
Lets say the database has 30 tables.
Just want to know your opinions!
Regards
Cecil
|
|
|
|
|
cecildt wrote: What is a better design in visual studio.
Visual Studio is the IDE. You can do all this stuff in notepad if you want. It has nothing to do with Visual Studio.
cecildt wrote: To create separate datasets for each database table or
one dataset with all tables on the dataset.
Or don't use datasets at all. I don't use them much. I see no need for them. I query the database and everything gets mapped into my business objects.
|
|
|
|
|
I know Visual Studio is the IDE.
Just want to know how people are using the DataSets.
Thanks for your responds.
O, use Notepad++ not notepad!
|
|
|
|
|
cecildt wrote: Just want to know how people are using the DataSets.
I don't. I use business objects. Most serious advice on the subject recommends not using DataSets because of their being a bit overkill and their lack of type safety.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
cecildt wrote: use Notepad++ not notepad!
I was just saying that any two-bit text editor can be used.
cecildt wrote: Just want to know how people are using the DataSets.
As Pete said, they shouldn't be using them in serious applications. For quick throw away or hobby applications they have their uses.
|
|
|
|
|
I've only started using datasets, so I'm no expert, but I favour one dataset per functional area. For example, I have one dataset for invoicing, with procucts, documents, and customers tables, where the customers table only has the customer data required for invoicing.
Calling all South African developers! Your participation in this local dev community will be mutually beneficial, to you and us.
|
|
|
|
|
Hi, I would like to know that how i can find any source for writing ReportViewer properties in my ReportForm.cs such as page setup,setting margins,printing and ...
D.Riazi
|
|
|
|
|
driaziran wrote: Hi, I would like to know that how i can find any source for writing ReportViewer properties in my ReportForm.cs such as page setup,setting margins,printing and ...
Why aren't you asking this question in the thread you created 3 slots down? What do you feel is wrong with that thread? What is wrong with the response you recieved already? Have you done any research yourself yet? Where are you stuck in your attempt to do this yourself?
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Hi, thanks for your response.but i don't want to creat any Report with Crystal Report.
I want to use Object Reporting with ReportViewer tool in C#.
D.Riazi
|
|
|
|
|
This[^] article was in the Top 10 hits in a google search for ReportViewer example[^]
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
This[^] article was in the Top 10 hits in a google search for ReportViewer example[^]. See if that article, or any of those links gives you a good starting point.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Hi,
I’m loading XML into a DataSet using the following…
// Create a new Customer DataSet.
CustomerDS = new DataSet();
// Get a handle to the Customer.xml file.
CustomerFileHandle = new FileStream(CUSTOMERXMLFILEPATH, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
// Read the Customer XML file into the DataSet.
CustomerDS.ReadXml(new XmlTextReader(CustomerFileHandle));
This loads the information into the DataSet and it can all be viewed on my Form.
After making changes to my data, I then want to update the XML file. To do this I’m using the following code…
XmlTextWriter CustXmlWriter = new XmlTextWriter(CustomerFileHandle, System.Text.Encoding.Unicode);
// Write to the file with the WriteXml method.
CustomerDS.WriteXml(CustXmlWriter, XmlWriteMode.IgnoreSchema);
CustXmlWriter.Close();
// Close the Customer XML File.
CustomerFileHandle.Close();
This is not producing valid XML. All data (the xml) is being repeated at the end of the file with a NULL character in between each character.
Any help on this would be much appreciated.
Thanks in advance.
|
|
|
|
|
I am not sure why that isn't working. However, why don't you try taking a different taking a different route to your solution? Something like this:
CustomerDS = new DataSet();
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(XML_FILE);
xmlDocument.Save(XML_FILE);
Just a thought
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
How is it that I get my XML file into my DataSet?
|
|
|
|
|
just finished reading section 26.1 from C# specification.. I got a few questions regarding this new feature...
1. Why do we need "Implicitly typed local variables" (similar to "var" in JS)? Is it created especially for LINQ?? If LINQ is not used in the application, this kinda variable won't be required anymore, isn't it?
2. Let's say I wrote like that "var myvar = 1;". then, C# compiler will assume my variable "myvar" is int, right? Actually, I declared it as long.. What about "int vs uint", "long vs ulong" and "double vs float vs decimal"??
Since I haven't read about LINQ in details, I don't see any good point about using "Implicitly typed local variables"
What do you think?
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
Michael Sync wrote: Why do we need "Implicitly typed local variables" (similar to "var" in JS)? Is it created especially for LINQ?? If LINQ is not used in the application, this kinda variable won't be required anymore, isn't it?
It is not similar to var in js. A var in C# remains one type throughout once set.
var a = 5;
a = "five"; // This will throw a compiler error
Its inclusion is mainly to support LINQ. It is also required if you are using another new features called anonymous types. (What do you declare the reference if the type is anonymous)
Michael Sync wrote: Let's say I wrote like that "var myvar = 1;". then, C# compiler will assume my variable "myvar" is int, right? Actually, I declared it as long.. What about "int vs uint", "long vs ulong" and "double vs float vs decimal"??
You probably wouldn't use it in those situations. It wasn't what is is designed for. The only time is is REQUIRED is for anonymous types.
If you know the type then use the type.
Michael Sync wrote: What do you think?
I think it is something that I'll use from time to time when I need to use an anonymous type. However, if I know the type then I'll use the type. It is as simple as that.
However, I can forsee a lot of people getting it wrong then getting confused and asking questions about why they can't pass their variable into other methods or return it from a method.
|
|
|
|
|
Thanks a lot, Colin
Colin Angus Mackay wrote: anonymous types.
good point. ya... I missed it out... " Implicitly typed local variables" are good for LINQ and anonymous type, something that makes our code unreadable...
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
I see it as being handy when you create a new object of some type using reflection, when you don't know the type beforehand. Then, you have a strongly typed variable instead of just the interface or an object to work with. For example, lets say I implement a class that doesn't implement IList, but it comes close. So I write a method that takes an object, but the object must have an "Add" method. I think var may be helpful in this case, but only if you can do the following with it...
public void SomeMethod(object someObject) {
var foo = (someObject.GetType())someObject;
foo.Add(...);
}
As for the second question, you would have to explicitly state what type of variable it is. So you would have to say something like...
var f = 1f; // float
var u = (uint)1;
var l = (long)1;
etc.
Jeff
|
|
|
|
|
Skippums wrote: I see it as being handy when you create a new object of some type using reflection, when you don't know the type beforehand.
The thing is the compiler has to know the type. If it isn't an anoymous type (where the actual type is known only to the compiler) then you and the compiler should know the same thing. (I wrote a blog entry on what happens under the hood with anonymous types[^])
Skippums wrote: public void SomeMethod(object someObject) {
var foo = (someObject.GetType())someObject;
foo.Add(...);
}
I don't have VS2008 in front of me, but I doubt that is possible. The cast must be a literal or known at compiler time. This isn't.
|
|
|
|
|
Colin Angus Mackay wrote: I wrote a blog entry on what happens under the hood with anonymous types[^])
great one.. Thanks. I have subscribed your feed. Thanks..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
Michael Sync wrote: 1. Why do we need "Implicitly typed local variables" (similar to "var" in JS)? Is it created especially for LINQ?? If LINQ is not used in the application, this kinda variable won't be required anymore, isn't it?
They are only needed when the variable type is created in the compilation, so that it's impossible for you to explicitly declare a reference for it.
Michael Sync wrote: 2. Let's say I wrote like that "var myvar = 1;". then, C# compiler will assume my variable "myvar" is int, right? Actually, I declared it as long.. What about "int vs uint", "long vs ulong" and "double vs float vs decimal"??
The compiler will not assume that the variable is an int. The variable is an int, as you have specified a literal int value for it.
If you want a different data type, you have to specify a literal value of a different type. Like:
var first = 1U;
var answer = 42L;
var big = 1234567890UL;
var pi = 3.1416;
var size = 12.5F;
var price = 27.99M;
However, you should really never use this syntax with numeric literals, as it's not very obvious what the data type is.
A possible use where it makes sense, is where the data type is actually stated in the statement so that it's superflous to repeat it, like:
var b = new System.Web.UI.HtmlControls.HtmlInputRadioButton();
vs.
System.Web.UI.HtmlControls.HtmlInputRadioButton b = new System.Web.UI.HtmlControls.HtmlInputRadioButton();
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
thank you, Guffa. I'm clear now..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
I have a c# app that stores pdfs. I'd like to run a routine against the pdfs that changes them to searchable pdfs. Does anyone know how to accomplish this - I have adobe 8 on the server and not sure if there are any apis.
|
|
|
|