Error while creating a method that returns an Array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Khurram

    Error while creating a method that returns an Array

    Hi,
    Get the following error when trying to create a method that returns a
    one-dimentional array.

    You must implement a default accessor on System.Array because it
    inherits from ICollection.

    Below is how I am writing the method.

    public Array Diagnosis(DataS et assessmentData)
    {

    //Do some logic work with assessmentData DataSet

    //An array of SNOMED CT coded possible diagnosis results
    int[] diagnosis = { 74400008, 162031009, 7093002, 76581006,
    75694006};

    return diagnosis;
    }

    New to both Arrays and Csharp so any help will be greatly appreciated.
    I thought it was a namespace problem but I have "using System;"
    namespace added.


    Thank you kindly

    Khurram

  • Greg Young

    #2
    Re: Error while creating a method that returns an Array

    public int [] Diagnosis(DataS et assessmentData) {}

    should fix it for you

    Cheers,

    Greg Young
    MVP - C#


    "Khurram" <knahmad@gmail. comwrote in message
    news:1153611709 .554173.268880@ b28g2000cwb.goo glegroups.com.. .
    Hi,
    Get the following error when trying to create a method that returns a
    one-dimentional array.
    >
    You must implement a default accessor on System.Array because it
    inherits from ICollection.
    >
    Below is how I am writing the method.
    >
    public Array Diagnosis(DataS et assessmentData)
    {
    >
    //Do some logic work with assessmentData DataSet
    >
    //An array of SNOMED CT coded possible diagnosis results
    int[] diagnosis = { 74400008, 162031009, 7093002, 76581006,
    75694006};
    >
    return diagnosis;
    }
    >
    New to both Arrays and Csharp so any help will be greatly appreciated.
    I thought it was a namespace problem but I have "using System;"
    namespace added.
    >
    >
    Thank you kindly
    >
    Khurram
    >

    Comment

    • Khurram

      #3
      Re: Error while creating a method that returns an Array

      Thank you greg, worked like a charm

      Khurram

      Greg Young wrote:
      public int [] Diagnosis(DataS et assessmentData) {}
      >
      should fix it for you
      >
      Cheers,
      >
      Greg Young
      MVP - C#

      >
      "Khurram" <knahmad@gmail. comwrote in message
      news:1153611709 .554173.268880@ b28g2000cwb.goo glegroups.com.. .
      Hi,
      Get the following error when trying to create a method that returns a
      one-dimentional array.

      You must implement a default accessor on System.Array because it
      inherits from ICollection.

      Below is how I am writing the method.

      public Array Diagnosis(DataS et assessmentData)
      {

      //Do some logic work with assessmentData DataSet

      //An array of SNOMED CT coded possible diagnosis results
      int[] diagnosis = { 74400008, 162031009, 7093002, 76581006,
      75694006};

      return diagnosis;
      }

      New to both Arrays and Csharp so any help will be greatly appreciated.
      I thought it was a namespace problem but I have "using System;"
      namespace added.


      Thank you kindly

      Khurram

      Comment

      Working...