Create A Static Class Like System.Math

Mar 6, 2010

I have a module with generic constants, subs and functions.I would like to be able to use the module in multiple projects in one solution.I also want it to work like the class System.Math, where you do not need to declare and instance of the class before you can reference it.[code]I want to be able to call ClassLibrary1.MyGenerics.Half() just like I can call System.Math.Abs()

View 10 Replies


ADVERTISEMENT

"Import" A Static Class In C# Such As System.Math?

Oct 9, 2010

Is there a way to "Import" a static class in C# such as System.Math? I have included a comparison.[code]...

View 3 Replies

Asp.net - .Net Iniatialising A Class Using System.Reflection And System.Type To Create A Session Based Singlton Extension Method

Jun 11, 2009

I have had several occasions recently to access a specific class several times over a relatively small time frame.So I've been storing the value of the class in Session and trying to access it on page load, if it's not available creating a new instance and storing that in session.

So instead of constantly replicating the same code for different classes on different pages I'm trying to create an extension method to do this for me.

[Code]...

I'm stuck on what to do when I make my new instance of my class (it would have to have a New() sub)

I'm not sure where to go from here... or even if this is the best way to do it.

View 2 Replies

VB2010 Class Library: Create A Static Library Instead Of DLL?

Jun 21, 2011

I have a Visual Basic Class Library project. It generates a DLL. Is there a method to generate a static .LIB to which I can do a static link?Alternatively, can I do a static link against a DLL?

View 6 Replies

IDE :: Association To Static Class In Class Diagram

Jan 24, 2010

I'm wondering why I can't create an association from a class to a static class in the class diagram editor of VS. Any reason for this?

View 1 Replies

Use System.io.packaging To Create Own Zip Class?

Apr 28, 2010

I'm trying to use system.io.packaging to create my own zip class. I've got it to work, but i'm not happy with the compression rate. In the code below I've set it to the maximum compression rate, yet winrar is able to create a zip (at maximum compression) that is 2/3 of the size when I make it. Am i doing something wrong?

[Code]...

View 4 Replies

.net - Allow Math To Occur On Instances Of Class?

Nov 27, 2010

Is there some interface I can implement to allow basic comparisons and math to happen as it would an integer?

For example, let's say I have the following class:

Public Class Something
Public SomeBigNumber as UInt64
End Class

I would like to do something like this:

Dim SomethingA, SomethingB, SomethingC as New Something
....
If (SomethingA-SomethingB) > SomethingC Then
'Do stuff
End If

I was hoping to be able to implement some interface (if that is even the right term for it) that would return the UInt64 contained in the class for comparison and math, if possible.

View 1 Replies

Only Calculation In Radian In Math Class?

Jan 27, 2010

I use Math.Tan(str) for example (str = 35)

I become 0.47... But how can I calculte it in Deg., and Grad., to?

View 6 Replies

What Is Equivalent Of A Static Class

Nov 30, 2007

what is the Equivalent of a Static class in VB.Net. Is it Modules?And When i used one of the C# to VB.Net conversion tools then the code "Public Static class Class1 " was converted to "Public NotInheritable Class Class1"

View 1 Replies

C# - Reset A Static/shared Class?

May 4, 2009

I've got a shared class (static in C#) which mostly carries some settings data that any class in the application can read and sometimes write. Also there are some static properties which holds some internal states.

Now I want to revert this class to initial stage of it. With all default variables etc. Assume that the user want to reset the current state and start over without restarting the application.

In a singleton model I'd simply renew it with something like this :

Public Sub Reset()
_Instance = New MyClass()
End Sub

However this is not possible in a Shared class. Or should I switch back to Singleton?

View 3 Replies

Call A C# Class's Static Method ?

Oct 28, 2010

I have a C# dll and want to use it in VB.NET. I'm using C# 2008 Express and VB 2008 Express. I have added a reference in a VB project to the C# dll. When I create an instane of a class in the C# dll, it gives the following error messsage: "Type 'RF.RabinFingerprint' has no constructors". My C# dll code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;[code].......

View 3 Replies

Converting A Static C# Class To VB Module?

Dec 3, 2009

I am trying to convert following code into a VB equivalent so that I can use it with threading my forms and controls.

using
System;
using
System.Collections.Generic;

[code]....

View 3 Replies

Equivalent Of A C# Internal Static Class?

Jun 9, 2010

If I have a module in a VB.Net class library, will it's visibility be limited to the assembly? What I'm looking for is the VB.Net equivalent of a C# internal static class.

View 1 Replies

Set A Module To Behave Like A Static Class?

Feb 9, 2010

This questions is for VBers, it's irrelevant in C#.

In VB, when you create a module, all it's fucntions and members are available in the scope without need to type the module name, just like all the VB functions (Rnd, Mid, IIf etc.).

I want to create a module but I should have to explicitly write it's name to access it's members, i.e. it shouldn't be loaded to the scope like a namespace.

Update

For example, I have a Module of extension methods, I don't want all it's members to show up on the scope and in the intellisense.

I want it to be available only by instance.ExtensionMethod().

View 3 Replies

VS 2010 Hmwk - Display The Largest And Smallest Using Math.max - Math.min

Mar 5, 2012

well i am having a couple of issues with this particular homework problem and this is my first programming class so there is probably quite a few mistakes well the homework problem is to take three double values entered by a user and display the largest and smallest using math.max and math.min and display the smallest and largest so i thought i could use a listbox and take the values that went to the listbox and assign variables to each so i can try to use each variable in the math.max and min but im not making it to far and i actually might be way off

[Code]...

View 4 Replies

.net - When Are Inline Static Variables Initialized In A Class

Aug 10, 2010

Suppose we have a class like:

Public Class Question
Private Shared _field as Integer = CrazyIntegersRepository.GetOne()
' Some other useful things go here
End Class

And the method GetOne throws an exception... How can we manage that? Is a good practice to rewrite that into a static constructor? When is the GetOne method going to be executed if we leave it there in the inline _field declaration?

View 3 Replies

Class-level Static Variable Per Instance?

Jan 28, 2010

I need a static variable to get a ListItemCollection from a List control (I can do this, but if I don't set it as Shared It's not preserving the values as it should). The thing is that this class is a SharePoint webpart, so I most probably will be using the webpart more than once, and I need this variable to be unique to each webpart, which shared doesn't accomplish.I tried everything you can imagine. I placed a Static variable within a Sub (shared and not shared), I tried it with Properties (also Shared and not shared)...

View 3 Replies

Get Name Of Class Without Instantiating Object Or Having A Static Method?

Feb 22, 2011

I hate to see the name of the class used as a string parameter like "FileDownloader" in the code, and I would like to use something like this FileDownloader.Name(), where FileDownloader is name of the class.Only problem is that I can't find out how to do that without instantiating object or creating a static method..Is there a way to get a class name in .net without having the object instance and without creating a static method that returns the name of the class?

View 4 Replies

Storing Static Data In Class Library?

Jun 21, 2011

I want to store a fairly large amount of static data in a class library.I have used a library before that does this, containing info for thousands of items. The person who made the library got that info from a database and somehow stored it in the library such that you could access it in a variety of ways using different methods. (ID, Name, etc)

View 5 Replies

Use A Static Variable That Is Referenced To In The Class's Children?

Oct 11, 2009

how to word this, as it is it's complex to understand the concept of the idea. Basically, I'm trying to use an interpreter pattern, based off of the code I used in php. In php the code is:

abstract class Expression {
private static $keycount=0;
private $key;
[code]......

The problem I'm having is that the static variable is blank for each child using it. How can I have it where one child increases the keycount,and ALL of the children have the new keycount variable?

View 3 Replies

Singleton Class Or Shared (static) Member Functions?

Aug 9, 2011

I would like to understand the Pro & Cons in using the commonly used methods via Singleton class against Shared (Static) members of a class in VB.Net. It could be in terms Time, Space complexity or best practices. I have a BankAccount class with methods doing some business logic.

GetBalance()
GetLast5Credits()
GetMiniStatement()

[code].....

View 4 Replies

Create A Program To Calculate Math Grade?

Feb 19, 2010

I ma trying to create a program to calculate my math grade. The way my math teacher explained the grading scale was each test is worth 1 point and each quiz is worth .2 points.

So as an example (add both sides up then divide by both sides)

100 =1
80 = 1
15 = .2
18 = .2

213 divide by 2.4 which equals your grade of 88.75

There are more quizs and tests in the semester and I want the numbers to change with the number of quizs and tests entered. The only problem is I am not sure how to code it. I though I would use IF AND statements but I am not sure where to start.

View 8 Replies

Can't Define A Specific Instance Of Static Method Created As A Java Class

Mar 12, 2011

Under Visual Basic 2010, I am trying to define a specific instance of a static method that was created as a Java class. I have a vendor supplied dll added in as a reference.[code]...

But, I can't seem to define a specific instance of this method. Using "IntegrationMethod.getIntegrationMode()"always returns a value of zero.

There doesn't appear to be any way to "setIntegrationMode" to a specific value.

The documentatoin for this Class as provided by the vendor are shown below.

When I asked the vendor for assistance, their response was: "

Our javadocs for the IntegrationMethod class show that we provide three predefined instances of the IntegrationMethod class[code]...

View 9 Replies

Create A Dynamic Map Instead Of Static Map For Standalone Application?

Mar 26, 2010

Currently i only managed to implement the google map(static) into my application,but i want to replace it with a dynamic map. Is there any website or example for me to refer? I tried reading up google API website, but i still dont get it.

View 2 Replies

Error - Base Class 'System.Windows.Forms.Panel' Specified For Class 'MenuButton' Cannot Be Different From The Base Class 'System.Windows.Forms.UserControl'

Mar 12, 2010

When I do this

Public Class cInherits : Inherits Panel

I get this: Base class 'System.Windows.Forms.Panel' specified for class 'MenuButton' cannot be different from the base class 'System.Windows.Forms.UserControl' of one of its other partial types.

How do I inherit?

View 4 Replies

Imports System.math - Getting Errors: Error1'Imports' Statements Must Precede Any Declarations?

Apr 23, 2012

Public Class Form1
Imports System.Math
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load[code].....

For some reason, when i try to start the program im getting the following errors: Error1'Imports' statements must precede any declarations.C:Vb10sbschap05My Framework MathMy Framework MathForm1.vb25My Framework Math

Error2'Sqrt' is not declared. It may be inaccessible due to its protection level.C:Vb10sbschap05My Framework MathMy Framework MathForm1.vb1018My Framework Math

Im using Visual Basic Express 2010.This is from a tutorial in Microsoft Visual Basic 2010 Step by Step

View 3 Replies

Dynamically Create Another PictureBox On The Form While The Program Runs (to The Left Of The Static One)?

Aug 12, 2011

I've created a form with a PictureBox on it and would like to dynamically create another PictureBox on the form while the program runs (to the left of the static one). I've written this code:

Dim temp As PictureBox
temp = New PictureBox
temp.Image = StaticPictureBox.Image
temp.Visible = True

[code]....

When I run this code I can detect that the temp PictureBox does get created. However, it is not rendered onto the form. It seems like it's there but is invisible.

View 8 Replies

Use A Decimal Instead Of A Double (why Then Do Microsoft Use A Double For Most Math Class Functions)

Aug 15, 2011

For greater accuracy I should use a Decimal instead of a Double ( so I've been told ). Why then have Microsoft chosen to use DOUBLE for most of the functions that return a floating point value in the Math Class?

[Code]....

View 9 Replies

Interface And Graphics :: Making A Custom Class That Mocks The System.Drawing.Rectangle Class?

Jul 6, 2010

I'm making a custom class that mocks the System.Drawing.Rectangle class because the Rectangle class doesn't have a name property. I need a name property because I am adding all of my rectangles to a collection and I need a little more info stored than just their locale and size. So I changed the _onPaint event but nothing is working out when I run the program?

Public Class Rectanglar : Inherits UserControl
Public BackgroundColor As Color = Color.Blue
Public Sub New(ByVal name As String, ByVal XY As Point, ByVal Widthy As Integer, ByVal Heighty As Integer)

[code].....

View 5 Replies

Use Variables Or Properties, And Global Or Static Variables In A Class?

Jun 9, 2012

I'm new in .NET programming.I have a class Form1 that includes Button1_Click event.Button1_Click creates a multiple Text Boxies at run time)Here is the class:

Public Class Form1
Dim shiftDown As Integer
Dim counter As Integer

[code].....

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved