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_FONTPATH"))
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.