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. Web Development
  3. ASP.NET
  4. Error in Creating Structs

Error in Creating Structs

Scheduled Pinned Locked Moved ASP.NET
help
2 Posts 2 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.
  • C Offline
    C Offline
    chitra4sat
    wrote on last edited by
    #1

    Hey All, i am new to programming and they asked me to create a struct for calculating Area with the length and width. I have coded but it shows error and please help me to correct the error and i will paste my code here. Struct Area { Public int length; Public int width; Public int area; Public Area(int _length, int _width) { this.length=_length; this.width=_width; this.area=(_length* _width); } Public int GetArea() { return area; } static void main(int[] args) { Area area=new Area(); Console.Writeline(area.GetArea()); } } Chitra

    R 1 Reply Last reply
    0
    • C chitra4sat

      Hey All, i am new to programming and they asked me to create a struct for calculating Area with the length and width. I have coded but it shows error and please help me to correct the error and i will paste my code here. Struct Area { Public int length; Public int width; Public int area; Public Area(int _length, int _width) { this.length=_length; this.width=_width; this.area=(_length* _width); } Public int GetArea() { return area; } static void main(int[] args) { Area area=new Area(); Console.Writeline(area.GetArea()); } } Chitra

      R Offline
      R Offline
      Rhys Gravell
      wrote on last edited by
      #2

      chitra4sat wrote:

      Area area=new Area();

      You have no public constructor with this signature. Your only constructor takes two arguments, (int _length and int _width). Either add a new constructor with no parameters, or call the existing constuctor with the appropriate arguments; Area area=new Area(0, 0);

      Rhys

      ELYSIUM, n. An imaginary delightful country which the ancients foolishly believed to be inhabited by the spirits of the good. This ridiculous and mischievous fable was swept off the face of the earth by the early Christians -- may their souls be happy in Heaven!

      Ambrose Bierce (1842 - 1914)

      Behind every argument is someone's ignorance.

      Louis D. Brandeis (1856 - 1941)

      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