PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 9, 2022

[FIXED] What is the equivalent in F# of the C# default keyword?

 July 09, 2022     c#, c#-to-f#, default, f#, keyword     No comments   

Issue

I'm looking for the equivalent of C# default keyword, e.g:

public T GetNext()
{
    T temp = default(T);
            ...

Thanks


Solution

I found this in a blog: "What does this C# code look like in F#? (part one: expressions and statements)"

C# has an operator called "default" that returns the zero-initialization value of a given type:

default(int) 

It has limited utility; most commonly you may use default(T) in a generic. F# has a similar construct as a library function:

Unchecked.defaultof<int>


Answered By - blu
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing