C# Programing FAQ - Post here

asachan

Member
Apr 11, 2009
1,636
3
0
Athurugiriya
digitaldjs said:
vista integrates 2.0 version but if you use WPF WCF etc, you need 3.5 runtime.

Vista new release wala enne 3.5 machan. umba vista sevice pack eka gahuwwoth 3.5 walata update wenawa. meka ape Dev team eke ekak meka dakala kiwwe.

Api thama use kranne 2.0 . so vista walata api nikan package eka witharai denne .
Umba kiyapu kathawa hariyatama hari.
 

Ranhiru

Member
Feb 2, 2007
6,438
42
0
Inside FIREFOX
ran123456 said:
great work machanz :D
mata kiyapan machan btn clik event ekedi tab controller ekaka tab eka change karanne kohomada kiyala :D
thanx :)
sorry if this has being answered....

here u go...

Code:
private void button1_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedIndex = 1;
        }

Change the selected index to anything what u like starting from index 0...which is the first Tab :)
 

ran123456

Member
Sep 27, 2007
2,383
9
0
Somewhere in da middle
Ranhiru said:
sorry if this has being answered....

here u go...

Code:
private void button1_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedIndex = 1;
        }

Change the selected index to anything what u like starting from index 0...which is the first Tab :)

thanx machan :D
 

asachan

Member
Apr 11, 2009
1,636
3
0
Athurugiriya
Ranhiru said:
sorry if this has being answered....

here u go...

Code:
private void button1_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedIndex = 1;
        }
Change the selected index to anything what u like starting from index 0...which is the first Tab :)

Hey man
Nice answer i think it's very best
Welcome to the club friend
 

fazaal24

Member
Nov 10, 2006
33,026
18
0
Carbon Canyon Dehiwala
Buddy, any info on finding the Power of Power of an expression such as 2^3^2^ Using Stacks.

Can manage to do it, but finding difficult if the user enters a two digit number, like 12^3^2. How restrict it.

Thanks in advance.
 

chindaara

Member
Aug 9, 2007
505
1
0
මහරගම
database connect

macho
c# wala database ekak connect karanne kohomada
database connect karapu application ekak install karanna puluwan exe ekak hatiyata build karanne kohomada
 

asachan

Member
Apr 11, 2009
1,636
3
0
Athurugiriya
chindaara said:
macho
c# wala database ekak connect karanne kohomada
database connect karapu application ekak install karanna puluwan exe ekak hatiyata build karanne kohomada

1st question

There is a lot of type of connection and vast varity of DataBases are there.So here is how we can connect to a SQL database

Simple Connection Using .NET SQL DLL's
=============================

First you need to import
SqlClient ;
=========================
using System.Data.SqlClient;

Then you need to Create a Connection to the database
=======================================

With out Authentication
-------------------------
string conn = "server=KEVOL;database=StudentInfo;Integrated Security=true";

KEVOL = server name;
StudentInfo = database name;


With Authentication
---------------------

string conn = server = KEVOL;database = StudentInfo;uid = sa;pwd = 5j55j";
KEVOL = server name;
StudentInfo = database name;
sa = username
5j55j = Password



Test your connection
====================

SqlConnection scon = new
SqlConnection(conn);
scon.Open();

Compact it to one Line(Advanced stuff)
======================================
SqlConnection scon = new SqlConnection(conn).Open();




2st question

you don't have to do anything machan
SQL needs only server name , DB name and Authentication .
so you have to pass this entries in longing time and make the connection string.
so rest up to the application to handle

Setup eka build karranne Setup Project ekak solution ekata add karanna.

need more info on setups ask next

Jaya


 

asachan

Member
Apr 11, 2009
1,636
3
0
Athurugiriya
fazaal24 said:
Buddy, any info on finding the Power of Power of an expression such as 2^3^2^ Using Stacks.

Can manage to do it, but finding difficult if the user enters a two digit number, like 12^3^2. How restrict it.

Thanks in advance.

If i understand ur problem correctly, this is the solution i have

When u get the user input check if the number < 10 .

If not explain a lil bit of ur requirement pls

Jaya
 

Ranhiru

Member
Feb 2, 2007
6,438
42
0
Inside FIREFOX
asachan said:
If i understand ur problem correctly, this is the solution i have

When u get the user input check if the number < 10 .

If not explain a lil bit of ur requirement pls

Jaya
as i understand his problem machan he wants it to be a number less than 10.. but your solution is not going to work as it is going to be a char array which will take in the question.. such as 5^5 which should return the answer 3125 (5x5x5x5x5)... but what is the user enters a two digit number for the question...such as 5^10... then there is a problem of finding the proper answer...

Machan Fazaal i think what u should do is run the loop until u find a ^...add all the characters to a char array before the ^

and then pass the char array to a function named atoi

check how to use atoi

EDIT : atoi does not seem to be working on C#... but if its C# its gonna be even more easier because there is a String Class... and Int32.Parse could do the job... but what i feel is like you are asking for C help :D
 
Last edited:

asachan

Member
Apr 11, 2009
1,636
3
0
Athurugiriya
Ranhiru said:
as i understand his problem machan he wants it to be a number less than 10.. but your solution is not going to work as it is going to be a char array which will take in the question.. such as 5^5 which should return the answer 3125 (5x5x5x5x5)... but what is the user enters a two digit number for the question...such as 5^10... then there is a problem of finding the proper answer...

Machan Fazaal i think what u should do is run the loop until u find a ^...add all the characters to a char array before the ^

and then pass the char array to a function named atoi

check how to use atoi

EDIT : atoi does not seem to be working on C#... but if its C# its gonna be even more easier because there is a String Class... and Int32.Parse could do the job... but what i feel is like you are asking for C help :D


Machan what is his problem exactly?
as i understand he got some user input like this

2^2^2 and he want the answer of the equation by the end?. and if it was like 2^10^2 he face a difficult time to extract exact no's out from the stack

Is that his problem?
 

Ranhiru

Member
Feb 2, 2007
6,438
42
0
Inside FIREFOX
asachan said:

Machan what is his problem exactly?
as i understand he got some user input like this

2^2^2 and he want the answer of the equation by the end?. and if it was like 2^10^2 he face a difficult time to extract exact no's out from the stack

Is that his problem?

yes yes exactly machan!!! That is his problem :D
 

fazaal24

Member
Nov 10, 2006
33,026
18
0
Carbon Canyon Dehiwala
Ranhiru said:
as i understand his problem machan he wants it to be a number less than 10.. but your solution is not going to work as it is going to be a char array which will take in the question.. such as 5^5 which should return the answer 3125 (5x5x5x5x5)... but what is the user enters a two digit number for the question...such as 5^10... then there is a problem of finding the proper answer...

Machan Fazaal i think what u should do is run the loop until u find a ^...add all the characters to a char array before the ^

and then pass the char array to a function named atoi

check how to use atoi

EDIT : atoi does not seem to be working on C#... but if its C# its gonna be even more easier because there is a String Class... and Int32.Parse could do the job... but what i feel is like you are asking for C help :D

Woah thats great, never knew abt an atoi thing :) THanks a lot buddy :D Gotta try it out :D


asachan said:
If i understand ur problem correctly, this is the solution i have

When u get the user input check if the number < 10 .

If not explain a lil bit of ur requirement pls

Jaya

Thanks for the sup dude :D Keep up the good work guys :)
 

asachan

Member
Apr 11, 2009
1,636
3
0
Athurugiriya
fazaal24 said:
Woah thats great, never knew abt an atoi thing :) THanks a lot buddy :D Gotta try it out :D


Thanks for the sup dude :D Keep up the good work guys :)


Macho there is a better option in C# than stack
It's List<> genaric type.
U can create anytupe of list using this

List<string> lst = new List<string>;

and to add the records

lst.Add(<what ever string u have>);

to loop through the list

foreach(string str in lst){
// do anything u want with the str . it's a indexed string on the list. it's FIFO
}