Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4111050
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:00:59+00:00 2026-05-20T22:00:59+00:00

Is it possible to create static member indexed properties in F#? MSDN show them

  • 0

Is it possible to create static member indexed properties in F#? MSDN show them only for instance members, however, I’m able to define the following class:

type ObjWithStaticProperty =
    static member StaticProperty
        with get () = 3
        and  set (value:int) = ()

    static member StaticPropertyIndexed1
        with get (x:int) = 3
        and  set (x:int) (value:int) = ()

    static member StaticPropertyIndexed2
        with get (x:int,y:int) = 3
        and  set (x:int,y:int) (value:int) = ()

//Type signature given by FSI:
type ObjWithStaticProperty =
  class
    static member StaticProperty : int
    static member StaticPropertyIndexed1 : x:int -> int with get
    static member StaticPropertyIndexed2 : x:int * y:int -> int with get
    static member StaticProperty : int with set
    static member StaticPropertyIndexed1 : x:int -> int with set
    static member StaticPropertyIndexed2 : x:int * y:int -> int with set
  end

But when I try to use one, I get an error:

> ObjWithStaticProperty.StaticPropertyIndexed2.[1,2] <- 3;;

  ObjWithStaticProperty.StaticPropertyIndexed2.[1,2] <- 3;;
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error FS1187: An indexer property must be given at least one argument

I tried a few different syntax variations and none worked. Also weird is that when I hover over set in VS2010 for one of the definitions in the type, I get info about ExtraTopLevelOperators.set.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:00:59+00:00Added an answer on May 20, 2026 at 10:00 pm

    I believe that you call indexed properties using a different syntax (whether instance or static):

    ObjWithStaticProperty.StaticPropertyIndexed2(1,2) <- 3
    

    The only semi-exception to this is that an Item property on an instance x can be called via x.[...] (that is, Item is omitted and brackets are used around the arguments).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to create a static member in a class that would react
Possible Duplicate: Why can I only access static members from a static function? While
Is it possible to create a generic method with a signature like public static
Is possible to create a spinner in HTML? Only HTML? A tag maybe? My
Is it possible to explicitly create static objects in the CPU cache, sort of
So I want to create a text box static if possible that when my
Possible Duplicates: Factory Pattern. When to use factory methods? Why do static Create methods
Possible Duplicate: static members and LNK error in C++ What does it mean to
Possible Duplicate Why can't I have a non-integral static const member in a class?
I'm glad C# doesn't let you access static members 'as though' they were instance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.