[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Error

Posted on 2009-12-21
7
Medium Priority
?
238 Views
Last Modified: 2012-05-08
error.Question: Error      1      'chinesenewyear' is a 'variable' but is used like a 'method'      C:\inetpub\wwwroot\OmegaLove.Web\OmegaLove.Web\Components\ChineseZodiac.cs      43      27      OmegaLove.Web
Error      2      'chinese' is a 'variable' but is used like a 'method'      C:\inetpub\wwwroot\OmegaLove.Web\OmegaLove.Web\Components\ChineseZodiac.cs      69      20      OmegaLove.Web


using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace OmegaLove.Web
{


    public class ChineseZodiac
    {
        string[] chinese = new string[] { "Rat", "Ox", "Tiger", "Hare", "Dragon", "Snake", "Horse", "Sheep", "Monkey", "Fowl", "Dog", "Pig" };
        string[] branches = new string[] { "Zi", "Chou", "Yin", "Mao", "Chen", "Si", "Wu", "Wei", "Shen", "You", "Xu", "Hai" };
        string[] stems = new string[] { "Jia", "Yi", "Bing", "Ding", "Wu", "Ji", "Geng", "Xin", "Ren", "Gui" };

        float[] chinesenewyear = new float[] { 1.31F, 2.19F, 2.08F, 1.29F, 2.16F, 2.04F, 1.25F, 2.13F, 2.02F, 1.22F,  
        2.1F, 1.3F, 2.18F, 2.06F, 1.26F, 2.14F, 2.03F, 1.23F, 2.11F, 2.01F, 2.2F, 2.08F, 1.28F, 2.16F, 2.05F, 1.25F,
        2.13F, 2.02F, 1.23F, 2.1F, 1.3F, 2.17F, 2.06F, 1.26F, 2.14F, 2.04F, 1.24F, 2.11F, 1.31F, 2.19F,  
        2.08F, 1.27F, 2.15F, 2.05F, 1.25F, 2.13F, 2.02F, 1.22F, 2.1F, 1.29F,  
        2.17F, 2.06F, 1.27F, 2.14F, 2.03F, 1.24F, 2.12F, 1.31F, 2.18F, 2.08F,  
        1.28F, 2.15F, 2.05F, 1.25F, 2.13F, 2.02F, 1.21F, 2.09F, 1.3F, 2.17F,  
        2.06F, 1.27F, 2.15F, 2.03F, 1.23F, 2.11F, 1.31F, 2.18F, 2.07F, 1.28F,  
        2.16F, 2.05F, 1.25F, 2.13F, 2.02F, 2.2F, 2.09F, 1.29F, 2.17F, 2.06F,  
        1.27F, 2.15F, 2.04F, 1.23F, 2.1F, 1.31F, 2.19F, 2.07F, 1.28F, 2.16F
         };



        public static object GetChinese(int day, int month, int year)
        {
            float newYear = 0;
            int newMonth = 0;
            int newDay = 0;
            var chineseBranch = (year - 3) % 12;
            var chineseStem = (year - 3) % 10;

            if (((year > 1900) & (year < 1999)))
            {
                newYear = chinesenewyear(year - 1899);
                newMonth = Convert.ToInt32(Math.Floor(newYear));
                newDay = Convert.ToInt32(Math.Round((newYear * 100) - (newMonth * 100)));

                if (((month > newMonth) | ((month == newMonth) & (day >= newDay))))
                {
                    // this year  
                    chineseBranch = (year - 3) % 12;
                }
                else
                {
                    // last year  
                    chineseBranch = (year - 4) % 12;
                }
            }
            else
            {

                chineseBranch = (year - 3) % 12;
            }

            if ((chineseBranch == 0))
            {
                chineseBranch = 12;
            }

            return chinese(chineseBranch - 1);
       

    }
0
Comment
Question by:mathieu_cupryk
  • 4
  • 2
7 Comments
 
LVL 9

Assisted Solution

by:magicdlf
magicdlf earned 1332 total points
ID: 26101654
newYear = chinesenewyear(year - 1899);
should be
 newYear = chinesenewyear[year - 1899];
0
 
LVL 61

Accepted Solution

by:
HainKurt earned 668 total points
ID: 26101678
also

return chinese(chineseBranch - 1);
-->
return chinese[chineseBranch - 1];
0
 

Author Comment

by:mathieu_cupryk
ID: 26101747
The problem is that it is static
it does not like that?
What should I do?
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace OmegaLove.Web
{


    public class ChineseZodiac
    {
        public ChineseZodiac()
            {
                  //
                  // TODO: Add constructor logic here
                  //
            }

        string[] chinese = new string[] { "Rat", "Ox", "Tiger", "Hare", "Dragon", "Snake", "Horse", "Sheep", "Monkey", "Fowl", "Dog", "Pig" };
        string[] branches = new string[] { "Zi", "Chou", "Yin", "Mao", "Chen", "Si", "Wu", "Wei", "Shen", "You", "Xu", "Hai" };
        string[] stems = new string[] { "Jia", "Yi", "Bing", "Ding", "Wu", "Ji", "Geng", "Xin", "Ren", "Gui" };

        float[] chinesenewyear = new float[] { 1.31F, 2.19F, 2.08F, 1.29F, 2.16F, 2.04F, 1.25F, 2.13F, 2.02F, 1.22F,  
        2.1F, 1.3F, 2.18F, 2.06F, 1.26F, 2.14F, 2.03F, 1.23F, 2.11F, 2.01F, 2.2F, 2.08F, 1.28F, 2.16F, 2.05F, 1.25F,
        2.13F, 2.02F, 1.23F, 2.1F, 1.3F, 2.17F, 2.06F, 1.26F, 2.14F, 2.04F, 1.24F, 2.11F, 1.31F, 2.19F,  
        2.08F, 1.27F, 2.15F, 2.05F, 1.25F, 2.13F, 2.02F, 1.22F, 2.1F, 1.29F,  
        2.17F, 2.06F, 1.27F, 2.14F, 2.03F, 1.24F, 2.12F, 1.31F, 2.18F, 2.08F,  
        1.28F, 2.15F, 2.05F, 1.25F, 2.13F, 2.02F, 1.21F, 2.09F, 1.3F, 2.17F,  
        2.06F, 1.27F, 2.15F, 2.03F, 1.23F, 2.11F, 1.31F, 2.18F, 2.07F, 1.28F,  
        2.16F, 2.05F, 1.25F, 2.13F, 2.02F, 2.2F, 2.09F, 1.29F, 2.17F, 2.06F,  
        1.27F, 2.15F, 2.04F, 1.23F, 2.1F, 1.31F, 2.19F, 2.07F, 1.28F, 2.16F
         };



        public object GetChinese(int day, int month, int year)
        {
            float newYear = 0;
            int newMonth = 0;
            int newDay = 0;
            var chineseBranch = (year - 3) % 12;
            var chineseStem = (year - 3) % 10;

            if (((year > 1900) & (year < 1999)))
            {
                newYear = chinesenewyear[year - 1899];
                newMonth = Convert.ToInt32(Math.Floor(newYear));
                newDay = Convert.ToInt32(Math.Round((newYear * 100) - (newMonth * 100)));

                if (((month > newMonth) | ((month == newMonth) & (day >= newDay))))
                {
                    // this year  
                    chineseBranch = (year - 3) % 12;
                }
                else
                {
                    // last year  
                    chineseBranch = (year - 4) % 12;
                }
            }
            else
            {

                chineseBranch = (year - 3) % 12;
            }

            if ((chineseBranch == 0))
            {
                chineseBranch = 12;
            }

            return chinese[chineseBranch - 1];
        }

    }
}
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Assisted Solution

by:magicdlf
magicdlf earned 1332 total points
ID: 26101758
I compile it successfully in my environment. What's your problem?
0
 

Author Comment

by:mathieu_cupryk
ID: 26101762
when it is an object type it cannot be static?
0
 

Author Comment

by:mathieu_cupryk
ID: 26101769
ChineseZodiac CZ = new ChineseZodiac();
            lblChineseZodiac.Text = CZ.GetChinese(day, month, year).ToString();
0
 

Author Closing Comment

by:mathieu_cupryk
ID: 31668831
k
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question