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. static question

static question

Scheduled Pinned Locked Moved C#
questioncss
7 Posts 3 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.
  • O Offline
    O Offline
    Old Gun
    wrote on last edited by
    #1

    I am not sure my code,Is it right? public class Macro_RemoveExcelDefaultGridLines { /// /// Excel Macro : Remove Microsoft Excel's Default Grid Lines /// private static string _Name = "RemoveDefaultGrid"; private static string _Body ="" + " Sub RemoveDefaultGrid()\n" + " Cells.Select\n" + " With ActiveWindow\n" + " .DisplayGridlines = False\n" + " .DisplayZeros = False\n" + " End With\n" + "End Sub\n"; public static string Name { get{return _Name;} } public static string Body { get{ return _Body;} } }

    A 1 Reply Last reply
    0
    • O Old Gun

      I am not sure my code,Is it right? public class Macro_RemoveExcelDefaultGridLines { /// /// Excel Macro : Remove Microsoft Excel's Default Grid Lines /// private static string _Name = "RemoveDefaultGrid"; private static string _Body ="" + " Sub RemoveDefaultGrid()\n" + " Cells.Select\n" + " With ActiveWindow\n" + " .DisplayGridlines = False\n" + " .DisplayZeros = False\n" + " End With\n" + "End Sub\n"; public static string Name { get{return _Name;} } public static string Body { get{ return _Body;} } }

      A Offline
      A Offline
      alexey N
      wrote on last edited by
      #2

      Just try it directly in Excel, and see what you get. Best regards, Alexey.

      O 1 Reply Last reply
      0
      • A alexey N

        Just try it directly in Excel, and see what you get. Best regards, Alexey.

        O Offline
        O Offline
        Old Gun
        wrote on last edited by
        #3

        My Excel macro is test in excel,my mean is i am not sure my c# class,I use static private variable and property,I think there is somthing wrong.

        A G 2 Replies Last reply
        0
        • O Old Gun

          My Excel macro is test in excel,my mean is i am not sure my c# class,I use static private variable and property,I think there is somthing wrong.

          A Offline
          A Offline
          alexey N
          wrote on last edited by
          #4

          Old Gun wrote:

          I use static private variable and property,I think there is somthing wrong.

          Looks like all Ok. Try this, and if you'll get trobles, change properties to functions, or make them non-static. Best regards, Alexey.

          1 Reply Last reply
          0
          • O Old Gun

            My Excel macro is test in excel,my mean is i am not sure my c# class,I use static private variable and property,I think there is somthing wrong.

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            I see nothing wrong with the code. Why do you think that there is something wrong with it? If the class is only supposed to be a container for those static properties, you should make it sealed so that it can't be inherited, and make an empty private constructor to override the default empty public constructor, so that it's obvious that one should not create instances of the class. --- b { font-weight: normal; }

            O 2 Replies Last reply
            0
            • G Guffa

              I see nothing wrong with the code. Why do you think that there is something wrong with it? If the class is only supposed to be a container for those static properties, you should make it sealed so that it can't be inherited, and make an empty private constructor to override the default empty public constructor, so that it's obvious that one should not create instances of the class. --- b { font-weight: normal; }

              O Offline
              O Offline
              Old Gun
              wrote on last edited by
              #6

              Thanks alexey N and Guffa,Both of you helped me.

              1 Reply Last reply
              0
              • G Guffa

                I see nothing wrong with the code. Why do you think that there is something wrong with it? If the class is only supposed to be a container for those static properties, you should make it sealed so that it can't be inherited, and make an empty private constructor to override the default empty public constructor, so that it's obvious that one should not create instances of the class. --- b { font-weight: normal; }

                O Offline
                O Offline
                Old Gun
                wrote on last edited by
                #7

                Hi,Guffa,I can't understand "make an empty private constructor to override the default empty public constructor, so that it's obvious that one should not create instances of the class. ",Can you give me more tips?

                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