Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Math Question

Math Question

Scheduled Pinned Locked Moved C#
questioncsharp
12 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Miszou

    it's the percent symbol:

    int n = 10 % 3;

    n == 1


    Sunrise Wallpaper Project | The StartPage Randomizer | A Random Web Page

    M Offline
    M Offline
    Mark06
    wrote on last edited by
    #3

    Cheers Miszou

    1 Reply Last reply
    0
    • M Mark06

      Hey, anyone know the equivalent of VB's MOD, in C#? Cant find it :^)

      K Offline
      K Offline
      Kevin McFarlane
      wrote on last edited by
      #4

      For future ref try this: VB.NET and C# Comparison[^]

      Kevin

      1 Reply Last reply
      0
      • M Mark06

        Hey, anyone know the equivalent of VB's MOD, in C#? Cant find it :^)

        K Offline
        K Offline
        Kevin McFarlane
        wrote on last edited by
        #5

        Also, this site is pretty good Convert VB to C# and vice-versa[^]

        Kevin

        D 1 Reply Last reply
        0
        • K Kevin McFarlane

          Also, this site is pretty good Convert VB to C# and vice-versa[^]

          Kevin

          D Offline
          D Offline
          Daniel Grunwald
          wrote on last edited by
          #6

          Here is a .NET 2.0 online converter (built on the SharpDevelop code like yours, but using much more recent code): http://codeconverter.sharpdevelop.net/Convert.aspx[^]

          K 1 Reply Last reply
          0
          • D Daniel Grunwald

            Here is a .NET 2.0 online converter (built on the SharpDevelop code like yours, but using much more recent code): http://codeconverter.sharpdevelop.net/Convert.aspx[^]

            K Offline
            K Offline
            Kevin McFarlane
            wrote on last edited by
            #7

            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

            D 1 Reply Last reply
            0
            • K Kevin McFarlane

              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

              D Offline
              D Offline
              Daniel Grunwald
              wrote on last edited by
              #8

              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.

              K 1 Reply Last reply
              0
              • D Daniel Grunwald

                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.

                K Offline
                K Offline
                Kevin McFarlane
                wrote on last edited by
                #9

                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

                D 1 Reply Last reply
                0
                • K Kevin McFarlane

                  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

                  D Offline
                  D Offline
                  Daniel Grunwald
                  wrote on last edited by
                  #10

                  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; } }

                  // This is a test method
                  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() 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

                  K 1 Reply Last reply
                  0
                  • D Daniel Grunwald

                    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; } }

                    // This is a test method
                    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() 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

                    K Offline
                    K Offline
                    Kevin McFarlane
                    wrote on last edited by
                    #11

                    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

                    D 1 Reply Last reply
                    0
                    • K Kevin McFarlane

                      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

                      D Offline
                      D Offline
                      Daniel Grunwald
                      wrote on last edited by
                      #12

                      A snippet converter has now been added: http://codeconverter.sharpdevelop.net/[^]

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups