|
Hey,
anyone know the equivalent of VB's MOD, in C#?
Cant find it
|
|
|
|
|
it's the percent symbol:
int n = 10 % 3; n == 1
|
|
|
|
|
|
|
|
|
Daniel Grunwald wrote: Daniel Grunwald
Strangely, I remember trying something on that once and finding that it didn't work, so went back to the developerfusion hosted one. This would have been about a year ago.
Kevin
|
|
|
|
|
Send me a mail if something doesn't work. Note that our converter currently only accepts code that would be valid syntax as a file (whole compilation unit) - this means you can must post whole class definitions, code snippets won't be recognized correctly.
|
|
|
|
|
Daniel Grunwald wrote: Note that our converter currently only accepts code that would be valid syntax as a file (whole compilation unit)
Ah, that would be it then. In that case it would be more useful if it was like the developerfusion version.
Kevin
|
|
|
|
|
OK, I'll try to implement that.
But from a converter, I expect that it gets most things right. Here is a test case that our converter does right, but many others don't:
using System;
public class MyClass
{
string abc;
public string Abc { get { return abc; } }
static void M<T>(params T[] args) where T : IDisposable
{
Console.WriteLine("Hello!");
}
}
Difficulties:
1) realizing MyClass is not a valid identifier in VB
2) renaming abc to not conflict with Abc, since VB is case insensitive
3) not dropping comments
4) supporting generics - .NET 2.0 isn't new anymore in 2007
5) not messing up the ParamsArray parameter
6) noticing M<t>() is a private method because the C# default is private. In VB, it must read "Private Shared Sub" because the default visibility in VB is Public.
All of these at not uncommon in C# code (e.g. "Stop" might be a C# method name, but is VB keyword).
The Telerik converter is quite good (gets all except #2 and #6 right), our converter gets all right (because I created the example based on our unit tests), all others I tested failed miserably.
For SharpDevelop/NRefactory 3.0, I'm looking into making the converter aware of the code semantics - so that VB->C# can get a(1) converted to a[1] or a(1) depending on what a is. And make VB->C# fix up inconsistencies in the casing.
Last modified: 31mins after originally posted -- added difficulty 6
|
|
|
|
|
In my scenario I was:
1. Still using .Net 1.1.
2. Mostly doing C# to VB snippet conversions.
In this scenario, the developerfusion site was adequate enough.
I had been doing C# for a few years before having to work on a VB project.
It would be nice if you could get yours to do snippets though because often we see articles in one language, where we just want to convert a few lines or a method. Often there isn't a full compilation unit presented.
Kevin
|
|
|
|
|
|
I am trying to store strings with embedded escape characters in a resource file, for example:
An error occurred:\r\n{0} However, when the string is retrieved, the escape characters are not read correctly, and I end up with a string such as this:
An error occurred:\\r\\n{0} which is not terribly useful.
According to this[^] article, I can call
String.Replace( "\\r", "\r" ); on the string, but this seems a little silly...
Is this really the "standard" way of storing and managing escaped strings or am I missing something fundamental here?
|
|
|
|
|
|
It's not the escaping characters I'm having a problem with - it's the fact that I can't load them from a resource file without losing the fact that they're "special" characters.
For example, the newline character (\n) becomes two characters, a slash and the letter 'n'. I could run String.Replace on the string to turn it back to something useful, but it shouldn't be translating my string in the first place. Besides, running String.Replace just seems like a huge hack.
VC++ 6 could store and retrieve escaped strings from resource files with no problem, but I can't seem to get it to work as expected in Visual Studio 2005.
|
|
|
|
|
It is not translating your string - it is returning it unaltered. How should it convert \n into newline when it has no idea which programming language you are loading the string from? Not all languages use \n for newline.
Place a newline in the actual XML value. It should work from a technical point of view, but expect to loose it in translation (as in translate to other human languages, not escaping/unescaping). Hard coded newlines really do not belong in anything that should be translated, Make a resource for each line/paragraph instead, or calculate the newline position at runtime.
|
|
|
|
|
hi.
I'm making a contact us form with asp.net 1.1 & C# .
the form has textbox which people can type their name,email and message ...
then they click the "send" button.
I want to recieve their message and name and email in my inbox not in my database!
because I have written the code which can save the message in the database.but it doesnt the thing that I want.!
I want to recieve their message and name and email in my inbox( I mean my email address inbox ).
So,please tell me how to do it ?
thank alot
|
|
|
|
|
You can use the System.Net.Mail.MailMessage class to send yourself an email with all the relevant user contact info as demoed here[^]
|
|
|
|
|
hi 4 all
i need help from any one to scan image from scanner and insert it into database
scanning must done from application.
** Run my program , when i click "scan botton " scanning image and view it And save it to database
thank you 4 all
-- modified at 21:53 Friday 11th May, 2007
|
|
|
|
|
I have Form, and with a button, it launches a second form. I want the second form to "stay with" the first form. On top of it, in fact. But, not on top of everything else. Does any of this make sense? This is not MDI...
I've exhausted Google -- it's tired of me search for different variations of "form, window, child, parent, etc...".
Thoughts?
|
|
|
|
|
In your parent form, do this to create the child:
Form f = new Form();
f.Owner = this;
f.Show();
I hope that's what you were looking for
|
|
|
|
|
That was it. Thank you very much.
|
|
|
|
|
Hi friends, I am indeed in a hurry to get this thing done. I have a multi culture resource file
myResource.en-US.resx
myResource.fr-Fr.resx
I used the tool named ResXFileCodeGeneratorEX it works fine but when i tried to use multi cultural resouces I don't get the code behind means there is no code behind. But if I use the use the regualr resource file like myResource.resx the tool works completely fine and I do get all the properties public defined.
Could somebody show me how can I defined all the resources "Public" in a multi-cultural resource files.
I will appreciate thanks in advance
|
|
|
|
|
I am having a weird problem while validating an XML file against its schema. I am setting XmlReaderSettings to xml schema, add the ValidationEventHandler and then create the xml reader. But it throws an exception:
------------------
A first chance exception of type 'System.Xml.Schema.XmlSchemaValidationException' occurred in System.Xml.dll
validate function threw an exception of type 'System.Xml.Schema.XmlSchemaValidationException'
base {System.Xml.Schema.XmlSchemaException}: {"It is an error for both 'length' and either 'minLength' or 'maxLength' to be members of {facets}, unless they are specified in different derivation steps. In which case the following must be true: the {value} of 'minLength' <= the {value} of 'length' <= the {value} of 'maxLength'."}
SourceObject: null
-----------------------
I have validated the same xml file against the same schema using Oxygen XML Editor and XML Spy and these tools consider it a valid document.
Now after that I opened the schema in VS 2005, it underlines the xsd:length attribute and tootip gives the same error. But the above mentioned third party tools consider it valid attribute.
Any thoughts will be highly appreciated
-----
-----
|
|
|
|
|
Hi all,
I'm trying to copy a feature thats in Outlook. In the To field when creating a new email, if you type in an email address that you have used before, it will automatically display it and allow you to press enter.
Once you have done this, if you click on the email address, it selects it as a block and not as a piece of text. If you double click on it, it shows you information on that email address.
I am building an application for internal requests and would like the user to be able to type in the User's name in which the request is for, and on leaving the textbox, it will check the typed in User's Name and if it matches then it does what I described above, turns into an object and when you double click on it, it will show that users information.
I've played around with a Rich Text Box, and i've managed to get it to underline all the User's Names that are correct, but if I click on it, it will act as if its text (of course) and if the user continues typing it remains underlined.
Any idea's?
TIA
Gav
|
|
|
|