将C#代码转换为Vb.net [英] Conversion of C# code into Vb.net

查看:68
本文介绍了将C#代码转换为Vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..朋友,我在c#中有一个代码,但是我对vb.net并不了解,所以请任何人都可以将以下代码转换为vb.net代码

Hi.. friends i have a code in c# but I have no deeply knowledge in vb.net so plz anyone can convert the the below code into vb.net code

public void save_rec(string spname, SqlParameter[] p)
        {

            SqlConnection con = new SqlConnection("Data Source=PRANSHU\\SQLEXPRESS;Initial Catalog=test2;User ID=sa;Password=Webnsoft1");
            SqlDataAdapter adp=new SqlDataAdapter(spname,con);
            adp.SelectCommand.CommandType=CommandType.StoredProcedure;
            DataSet ds=new DataSet();
            for(Int32 i=0;i<p.length;i++)>
            {

                adp.SelectCommand.Parameters.Add(p[i]);
            }
            adp.Fill(ds);
        }





clstest obj = new clstest();
            SqlParameter[] p = { new SqlParameter("@ename", SqlDbType.VarChar, 50), new SqlParameter("@eadd", SqlDbType.VarChar, 50) };
            p[0].Value = textBox1.Text;
            p[1].Value = textBox2.Text;
            obj.save_rec("insemployee", p);
            MessageBox.Show("save");



在此先感谢

Parveen Rathi



Thanks in advance

Parveen Rathi

推荐答案

尝试一下:

http://www.developerfusion.com/tools/convert/vb-to-csharp/ [^ ]

在这里,您可以将vb转换为c#,反之亦然.

希望对您有所帮助:)
Try this:

http://www.developerfusion.com/tools/convert/vb-to-csharp/[^]

here you can convert from vb to c# and vice-versa.

hope it helps :)


请参阅: C#到VB转换器


大多数代码是相同的,但

Most of the code is the same but

private void save_rec(string spName, SqlParameter[] p)
{

}



成为



becomes

public sub save_rec(byval spName as string, p as sqlparameter())
end sub



可变声明



Varaible Declarations

sqlconnection con = new sqlconnection();



成为



becomes

dim con as sqlconnection = new sqlconnect("connectionStringHere")




对于循环




For loops

for(Int32 i=0;i<p.length;i++)>
{
}



成为



become

for i as integer = 0 to p.length -1
next



但是请注意,转换器之间的转换效果不好,因此您可能必须手动更改一些代码. telrik转换器 [ ^ ]



But please note that the converters don''t convert between them well so you may have to manually change some code. telrik Converter[^]


这篇关于将C#代码转换为Vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆