Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

C# Convert Class with C++ and others

0.00/5 (No votes)
27 May 2004 1  
ConvertTo,Math,Stack Classes to make your life easy with C++ 6.0

Introduction

I used to programming with C++ 6.0 from a time ago  ,and when the C#  come frist i don�t like it but when i work with it i feel comfortable because all relateded function are grouped together like there is a class that have all convert functions and a class that have all Math functions and a stack class and these classes have alot of function that we need but we don�t have time to make it by ower selves .so and because i still love C++ Because its the Powerful programming language in the world i grouped some function from the C++ Headers and i wrote some functions by my self and group it together in one LIB and some Headers.

Using:

to use  this LIB Past it in your solution folder .and in the  VC++6.0 menu(project ->Settings)

in the Link Tab in (object/library modules)box put the name of the lib like that(CSharp.lib)

and then add the header files in your project workspace with add file to project and then include the name of the header file in your cpp file like this

 

#include "Math.h";


I think all fuction are clear and have the same names in C++ and C#.

But i will discuss them

 

--------------------------------------------------------------------------------


Class Cconvert  that have all basic data types convertion like (int,double,float,long,byte,bool,Cstring )

Cconvert x;int i=19;
x.ToDouble(i);
x.ToString (i,4); //4 mean the digits number that you want to apear to user

//and so on...


--------------------------------------------------------------------------------


Class CIntStack  that take integer and put them in stack that encrease dinamicaly

 

CIntStack  s;
s.Push(6);
s.Push(7);
s.GetCount() ; //get the number of stack Elements.

Int buff=s.Pop();//buff =7;

buff= s.Pop();//buff=6;

buff=s.Pop();//buff=-1;

 

And you will find also CstringStack and CdoubleStack that have the same functions

 

--------------------------------------------------------------------------------


Class CMath tha have all math fuctions that we need plus some functions ..

 

CMath m;
m.Round(9.6);
m.Ceil(8.6);
m.Sin(2.7);//takes radians 

m.SinD(90);//takes Degree;

m.Mean(arr,size);//get the mean of array;

m.Median (arr,size);//get the Median of array;

m.Sort(arr,10);//Sort integer and double arrays and take the size of array

m.LinearSearch(arr,key,size);//key to be search with it and take double too;

m.BinarySearch(arr,key,size);//this function call sort function frist to sort the array ,and //take double

m.GetMaxInArray(arr,size);//get the max number in array int or double ,

m.GetMaxIndexInArray(arr,size);//get the index that have the max number.

m.GetMax(var1,var2,var3);//get the max between three numbers and also two number.

///and you will find also GetMin  functions like GetMax;and all regular math function //that you will need.

 


I Hope you like it please Send me if there any problems

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here