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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:56:33+00:00 2026-06-06T01:56:33+00:00

In VB.NET, I could make my math code a lot cleaner by Importing System.Math

  • 0

In VB.NET, I could make my math code a lot cleaner by Importing System.Math and referencing its methods directly:

Imports System.Math
[...]
Return New Vector3(Sin(az) * Cos(el), Cos(az) * Cos(el), Sin(el))

But I don’t think C# can Use classes in order to access their methods implicitly, so I have to do something like:

using System;
[...]
return new Vector3(Math.Sin(az) * Math.Cos(el), Math.Cos(az) * Math.Cos(el), Math.Sin(el));

But that’s ugly; it needs its own scroll bar!. Is there any way to write something in C# that looks like my VB.NET code? I could write local wrapper methods for Sin and Cos, but wouldn’t that reduce performance (because of the overhead of function calls)? And, that would require writing wrapper functions for every Math function I’m using in every class I’m using them in; that’s not so desirable either.

  • 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-06-06T01:56:34+00:00Added an answer on June 6, 2026 at 1:56 am

    You could give System.Math an alias with the using directive:

    using M = System.Math;
    
    return new Vector3(M.Sin(az) * M.Cos(el), M.Cos(az) * M.Cos(el), M.Sin(el));
    

    That’s the best I got.

    I could write local wrapper methods for Sin and Cos, but wouldn’t that reduce performance (because of the overhead of function calls)?

    You could, and at that point you could use generics and other niceties to make it even more convenient, but you would still be referencing a library like this, unless all the math was happening in the same class where this code is occuring as methods.

    The question of “performance from overhead” is answered with “additional stack frames for something this simple are non-noticeable for standard applications”. If you were in a tight loop, then yes, that would be an issue.

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

Sidebar

Related Questions

In ASP.NET I could make a user control to occupy more than one cell
With Windows Mobile development your .Net applications could make use of the GPS Intermediate
Previously when executing unit tests with xunit.net / testdriven.net I could see output written
In ASP.NET MVC I could define a textBox editor like this and give it
As far as theory goes it seems that Asp.net MVC framework could better be
for security reason, what is the minimum access level the asp.net membership user could
Could I use migrator.net bare migration framework and just have a set of SQL
How could i validate a textbox in vb.net, so that it gives error message
Firstly could you view my outcome http://jsfiddle.net/RXnKR/ From this I decided as you click
could somebody please take a look at this http://jsfiddle.net/bloodygeese/EzkFR/1/ My aim is to on

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.