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 7638987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:18:22+00:00 2026-05-31T08:18:22+00:00

How add key-value pair to instance on HashMultiMap that is member of declared by

  • 0

How add key-value pair to instance on HashMultiMap that is member of declared by the user type? maybe I’m doing something wrong

 #r"FSharp.PowerPack"
    type Test() = 
        member this.tmp = new HashMultiMap<string, int>(HashIdentity.Structural)
        member this.add name test = 
            this.tmp.Add(name, test)
    let t1 = new Test()
    t1.add "aaa" 1
    let a1 = t1.tmp.TryFind("aaa")
    let b1 = t1.tmp.Count
    //+
    let t2 = new HashMultiMap<string, int>(HashIdentity.Structural)
    t2.Add("aaa", 1)
    let a2 = t2.TryFind("aaa")
    let b2 = t2.Count

Output:

--> Referenced 'C:\Program Files\FSharpPowerPack-1.9.9.9\bin\FSharp.PowerPack.dll'


type Test =
  class
    new : unit -> Test
    member add : name:string -> test:int -> unit
    member tmp : HashMultiMap<string,int>
  end
val t1 : Test
val a1 : int option = None
val b1 : int = 0
val t2 : HashMultiMap<string,int>
val a2 : int option = Some 1
val b2 : int = 1
  • 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-31T08:18:24+00:00Added an answer on May 31, 2026 at 8:18 am

    Every time you call this.tmp you create a new multimap – you want to use

    type Test() = 
        let map =  new HashMultiMap<string, int>(HashIdentity.Structural)
        member this.tmp = map
        member this.add name test = 
            map.Add(name, test)
    

    note that new is only called once

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

Sidebar

Related Questions

I am trying to add a key value pair and having trouble adding the
How can I add a new key/value pair to an existing array inside of
How can I add key value pairs to an array? This won't work: public
I'm trying to add some additional key/value pairs to an NSMutableDictionary, using: Tag *tag1
The python interface to the memcache has an add method: add(key, value, time=0, min_compress_len=0,
I have two variables, key and value , and I want to add them
If I want to loop over a Dictionary(Key, Value)... why cant I add a
Is there anyway to add custom key/value pairs in the Routing file of a
I am trying to insert an key/value pair into a serializeArray(from jquery). So I
Suppose I have a string that looks like the following: string foo =<add key=key1

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.