C# to F# Convert public partial class Device : MarshalByRefObject

前端 未结 2 714
余生分开走
余生分开走 2021-01-18 03:40
public partial class Device : MarshalByRefObject
{
    internal bool FindTagName(string name, OneTag tag)
    {
        foreach (FuncSect fs in listFuncSect)
                


        
相关标签:
2条回答
  • 2021-01-18 04:20

    partial is a C# compiler feature, it ain't gonna work on F#, you will have to combined all the partial classes, or inherit from an existing one.

    0 讨论(0)
  • 2021-01-18 04:24

    As leppie says, there's no direct support for partial, although you could achieve a similar effect with intrinsic type extensions. F# does support internal methods, so your example would look like:

    // primary definition somewhere
    type Device() =
      inherit MarshalByRefObject()
      ...
    
    
    // type extension (roughly equivalent to partial class)
    type Device with
      member internal this.FindTagName(name:string, tag:OneTag) =
        listFuncSect
        |> Seq.exists 
             (fun fs -> 
                fs.listTags 
                |> Seq.exists (fun ot -> ot <> tag && ot.name = name))
    
    0 讨论(0)
提交回复
热议问题