"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


ADVERTISEMENT

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

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

.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

Cannot Import System.Windows.Media.Imaging And System.Windows.Forms Or System.Reflect?

Mar 16, 2009

With the following imported namespaces in my project :

Imports System.Windows.Forms
Imports System.Reflection
.. I cannot add..

[code].....

View 6 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

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

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

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

How To Import System.IO

Aug 16, 2011

I dont know how to and ever time i think i do it wont let me import

View 3 Replies

Import Class From C++?

Apr 6, 2010

This is probably a pretty dumb question but I am trying to use the BasicExcel class (from the CodeProject)and it is downloaded as a .cpp and a .hpp file. The project I want to use it in is in VB.NET.

I thought I just have to open the .cpp file in Visual Studio and save it as a vb class but it won't let me.

Can anyone tell me how to do this?

View 2 Replies

Import A Text File Into System?

Nov 23, 2009

We had a wierd problem at work.SOmeone at finance tried to import a text file into their system. It complained about the textfile was in unicode format. The file contains scandinavian . Apparently the ERP system that exported the file can only handle unicode.So one of our junior programmers wrote a batch program that line by line converted the unicode file to ascii (you can't choose encoding.ANSI because ANSI is byte array)

The files are rather big, about 3 GB in size.Apparently the system liked ASCII files, but sadly after this processing the and was gone and replaced with ?So, he wrote a new batch program, this time replacing m?nad with m�nad using String.Replace The file was opened using Encoding.Default and saved using Encoding.Ascii.Now the files HAVE AND can be imported. After he explained this to me, I just went . I wish I had some nifty "you should have done this... bla bla its much easier" but I am lost here in the jungle of code pages and encodings. Can someone that has their head screwed on straight enlight us *both* about why we had this problem and how it could be handled without writing the second batch program?

Basically unicode->non unicode (ascii) with the intact. I also noticed that if I use streamreader to read an ansi file with the internal strings will show ? instead.

View 1 Replies

Not Able To Import System.Printing In VB 2008

Oct 16, 2009

I am trying to develop an application to monitor and keep track of all the prints in the office.I have gone through some of the tutorial and found out system.printing has the functions to do so. But when I tried to import it, it says name space or type specified for system.import doesn't contain any public member or cannot be found.

View 2 Replies

C# - How To Import Namespace For ReportingService Class

Oct 27, 2011

I can't seem to find a clear answer as to how to import the proper namespace for ReportingService [URL]. I tried to follow the instruction here [URL] but there is no Add Web Service option showing when I create a console application. There is a service account. Should I just use that instead?

View 2 Replies

Import - Calling Class From Another File?

Apr 22, 2010

Lets say I have a class like this in class1.vb:

Public Class my_class
Public Sub my_sub()
Dim myvar as String
myvar = 10
Session("myvar") = myvar
End Sub
End Class

Then I have a ASP.NET page with a code-behind file, default.aspx and default.aspx.vb and I want to call my_class. I'm doing the following, but it doesn't work:

[Code]...

View 3 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







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