开发者

Convert the code in PHP to C#

What is C# equivalent of include function in php??i have to convert the following code in php to C#

if (file == "") file = str_replace(" ", "", family).strtolower(style) + " +ok sir php";
if (defined("FPDF_FO开发者_开发知识库NTPATH"))
file = FPDF_FONTPATH + file;
include(file);


There is no equivalent in C# - you cannot dynamically include a file into your source code.

The way to reuse code in C# is to use controls. As you are asking about PHP, I assume you mean ASP.NET and not Winforms or WPF, so you will need to create user controls or custom controls which you can reuse in your website.


Some code I used to "include" a menu file from another server.

    if (Application["menu"] != null)
    {
        litMenu.Text = Application["menu"].ToString();
    }
    else
    {
        try
        {
            System.Net.WebRequest wrq = System.Net.WebRequest.Create(ConfigurationManager.AppSettings["MenuPath"]);
            System.Net.WebResponse wrp = wrq.GetResponse();

            System.IO.StreamReader sr = new System.IO.StreamReader(wrp.GetResponseStream());
            litMenu.Text = sr.ReadToEnd();
            Application["menu"] = litMenu.Text;
        }
        catch
        {
            Application["menu"] = litMenu.Text;
        }

    }

The goal was to make our Intranet(PHP) and management backend(ASP.NET) look like the same system.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜