Click here to Skip to main content
15,894,539 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Local Polymorphism Pin
OriginalGriff3-Jan-21 8:56
mveOriginalGriff3-Jan-21 8:56 
GeneralRe: Local Polymorphism Pin
honey the codewitch3-Jan-21 9:02
mvahoney the codewitch3-Jan-21 9:02 
GeneralRe: Local Polymorphism Pin
Mike Hankey3-Jan-21 8:18
mveMike Hankey3-Jan-21 8:18 
GeneralRe: Local Polymorphism Pin
CPallini3-Jan-21 10:50
mveCPallini3-Jan-21 10:50 
GeneralRe: Local Polymorphism Pin
Daniel Pfeffer3-Jan-21 21:30
professionalDaniel Pfeffer3-Jan-21 21:30 
GeneralRe: Local Polymorphism Pin
honey the codewitch3-Jan-21 7:51
mvahoney the codewitch3-Jan-21 7:51 
QuestionRe: Local Polymorphism Pin
Espen Harlinn3-Jan-21 9:41
professionalEspen Harlinn3-Jan-21 9:41 
GeneralRe: Local Polymorphism Pin
Richard Deeming4-Jan-21 23:42
mveRichard Deeming4-Jan-21 23:42 
If you don't mind changing the case, just add:
C#
using static System.Math;
to the top of your code file.
C#
using static System.Math;

...

double cosX = Cos(x);
double cosY = Cos(y);
using static directive - C# Reference | Microsoft Docs[^]

Otherwise, a static (and possibly local) function would have better performance.
C#
private static double cos(double radians) => Math.Cos(radians);

private void Foo(double x, double y)
{
    double cosX = cos(x);
    double cosY = cos(y);
    ...
}
Or:
C#
private void Foo(double x, double y)
{
    static double cos(double value) => Math.Cos(value);
    
    double cosX = cos(x);
    double cosY = cos(y);
    ...
}
Local functions - C# Programming Guide | Microsoft Docs[^]



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralOur town is making signs using No Code Pin
theoldfool3-Jan-21 1:14
professionaltheoldfool3-Jan-21 1:14 
GeneralRe: Our town is making signs using No Code Pin
RickZeeland3-Jan-21 1:28
mveRickZeeland3-Jan-21 1:28 
GeneralRe: Our town is making signs using No Code Pin
OriginalGriff3-Jan-21 2:10
mveOriginalGriff3-Jan-21 2:10 
GeneralRe: Our town is making signs using No Code Pin
RickZeeland3-Jan-21 2:18
mveRickZeeland3-Jan-21 2:18 
GeneralWho is afraid of regex? Pin
honey the codewitch2-Jan-21 18:04
mvahoney the codewitch2-Jan-21 18:04 
GeneralRe: Who is afraid of regex? Pin
Kornfeld Eliyahu Peter2-Jan-21 19:23
professionalKornfeld Eliyahu Peter2-Jan-21 19:23 
GeneralRe: Who is afraid of regex? Pin
honey the codewitch2-Jan-21 19:45
mvahoney the codewitch2-Jan-21 19:45 
GeneralRe: Who is afraid of regex? Pin
Greg Cronin4-Jan-21 3:53
Greg Cronin4-Jan-21 3:53 
GeneralRe: Who is afraid of regex? Pin
Amarnath S2-Jan-21 19:34
professionalAmarnath S2-Jan-21 19:34 
GeneralRe: Who is afraid of regex? Pin
Peter_in_27802-Jan-21 19:39
professionalPeter_in_27802-Jan-21 19:39 
GeneralRe: Who is afraid of regex? Pin
RickZeeland2-Jan-21 20:12
mveRickZeeland2-Jan-21 20:12 
GeneralRe: Who is afraid of regex? Pin
Mike Hankey2-Jan-21 20:29
mveMike Hankey2-Jan-21 20:29 
GeneralRe: Who is afraid of regex? Pin
honey the codewitch3-Jan-21 1:40
mvahoney the codewitch3-Jan-21 1:40 
GeneralRe: Who is afraid of regex? Pin
Mike Hankey3-Jan-21 4:00
mveMike Hankey3-Jan-21 4:00 
GeneralRe: Who is afraid of regex? Pin
honey the codewitch3-Jan-21 4:19
mvahoney the codewitch3-Jan-21 4:19 
GeneralRe: Who is afraid of regex? Pin
Gary R. Wheeler3-Jan-21 4:44
Gary R. Wheeler3-Jan-21 4:44 
GeneralRe: Who is afraid of regex? Pin
Matt Bond4-Jan-21 2:32
Matt Bond4-Jan-21 2:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.