473,657 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

INCLUDE

Hi All,

Does somebody know how can I include an external file into my C# source
file?

I need to insert the same strings (about 5-10) into about 75 different
files, probably I will need to modify all these strings later, and I see it
as a good idea to use an INSERT approach, but C# is not C++ and doesn't
allow me just to insert some external file as I used to do. What's a command
for that?

Thanks,
Dmitri.
Nov 15 '05 #1
6 2046
Dmitri Shvetsov wrote:
Hi All,

Does somebody know how can I include an external file into my C# source
file?

I need to insert the same strings (about 5-10) into about 75 different
files, probably I will need to modify all these strings later, and I see it
as a good idea to use an INSERT approach, but C# is not C++ and doesn't
allow me just to insert some external file as I used to do. What's a command
for that?

Thanks,
Dmitri.


Create a class in its own file, and add the string constants to it.

e.g.:

public sealed class StringConstants
{
// private constructor to stop it getting instantiated
private StringConstants ()
{
}

public const string One = "One";
public const string Two = "Two";
}

Then later you can use StringConstants .One, etc.
Nov 15 '05 #2
Not so easy. I need to do the same steps during ON_LOAD for every asp page.
That's why I need to insert the same strings to compile them in different
classes. If I could use an external file and define a static variables etc.,
it would be a big difference.

Dmitri.

"C# Learner" <cs****@learner .here> wrote in message
news:e6******** ******@TK2MSFTN GP09.phx.gbl...
Dmitri Shvetsov wrote:
Hi All,

Does somebody know how can I include an external file into my C# source
file?

I need to insert the same strings (about 5-10) into about 75 different
files, probably I will need to modify all these strings later, and I see it as a good idea to use an INSERT approach, but C# is not C++ and doesn't
allow me just to insert some external file as I used to do. What's a command for that?

Thanks,
Dmitri.


Create a class in its own file, and add the string constants to it.

e.g.:

public sealed class StringConstants
{
// private constructor to stop it getting instantiated
private StringConstants ()
{
}

public const string One = "One";
public const string Two = "Two";
}

Then later you can use StringConstants .One, etc.

Nov 15 '05 #3
Dmitri,

Why don't you create a new class (let's call it MyPage) derived from Page, overload the OnLoad() method in MyPage, and then change the base type for every of your web pages' classes to MyPage instead of Page.

This technique is a very common technique for adding common functionality to web pages (it's almost like the master template page concept which will be available in ASP .NET "Whidbey").

--
Sorin Dolha [MCAD, MCSD .NET]
"Dmitri Shvetsov" <ds*******@cox. net> wrote in message news:fWU0c.1237 9$id3.3055@fed1 read01...
Not so easy. I need to do the same steps during ON_LOAD for every asp page.
That's why I need to insert the same strings to compile them in different
classes. If I could use an external file and define a static variables etc.,
it would be a big difference.

Dmitri.

"C# Learner" <cs****@learner .here> wrote in message
news:e6******** ******@TK2MSFTN GP09.phx.gbl...
Dmitri Shvetsov wrote:
Hi All,

Does somebody know how can I include an external file into my C# source
file?

I need to insert the same strings (about 5-10) into about 75 different
files, probably I will need to modify all these strings later, and I see it as a good idea to use an INSERT approach, but C# is not C++ and doesn't
allow me just to insert some external file as I used to do. What's a command for that?

Thanks,
Dmitri.


Create a class in its own file, and add the string constants to it.

e.g.:

public sealed class StringConstants
{
// private constructor to stop it getting instantiated
private StringConstants ()
{
}

public const string One = "One";
public const string Two = "Two";
}

Then later you can use StringConstants .One, etc.

Nov 15 '05 #4
Hi,

You know if it should be a very short code it would be fine, but it's only a part of the code and these few strings should be executed before the rest of the On_Load code that's different for each page and already done. So, I can't just derive the page from my own class. Although it could be a good idea and I will think about it. Maybe in this case we can avoid some extra code and just derive some common part of the code just sending the predefined constants to the constructors. Thanks.

Dmitri.
"Sorin Dolha [MCSD .NET]" <sd****@hotmail .com> wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Dmitri,

Why don't you create a new class (let's call it MyPage) derived from Page, overload the OnLoad() method in MyPage, and then change the base type for every of your web pages' classes to MyPage instead of Page.

This technique is a very common technique for adding common functionality to web pages (it's almost like the master template page concept which will be available in ASP .NET "Whidbey").

--
Sorin Dolha [MCAD, MCSD .NET]
"Dmitri Shvetsov" <ds*******@cox. net> wrote in message news:fWU0c.1237 9$id3.3055@fed1 read01...
Not so easy. I need to do the same steps during ON_LOAD for every asp page.
That's why I need to insert the same strings to compile them in different
classes. If I could use an external file and define a static variables etc.,
it would be a big difference.

Dmitri.

"C# Learner" <cs****@learner .here> wrote in message
news:e6******** ******@TK2MSFTN GP09.phx.gbl...
Dmitri Shvetsov wrote:
Hi All,

Does somebody know how can I include an external file into my C# source
file?

I need to insert the same strings (about 5-10) into about 75 different
files, probably I will need to modify all these strings later, and I see it as a good idea to use an INSERT approach, but C# is not C++ and doesn't
allow me just to insert some external file as I used to do. What's a command for that?

Thanks,
Dmitri.


Create a class in its own file, and add the string constants to it.

e.g.:

public sealed class StringConstants
{
// private constructor to stop it getting instantiated
private StringConstants ()
{
}

public const string One = "One";
public const string Two = "Two";
}

Then later you can use StringConstants .One, etc.

Nov 15 '05 #5
It doesn't matter how much code you need to run. And you can use the method I have described even if you have different code on the web pages OnLoad methods by overriding OnLoad twice, once in the MyBasePage (template) class and once in every web page's class, like this:

class MyBasePage : Page
{
public override OnLoad(...)
{
base.OnLoad(); // call the standard Page.OnLoad()

// next, your lines which should execute on every page
}

...
}

// repeat this for every page you currently have in the web site
// basically you will only need to insert "base.OnLoa d()" line, and change : Page to : MyBasePage for every web page class
class AWebPage : MyBasePage
{
public override OnLoad(...) // override
{
base.OnLoad(); //calls MyBasePage.OnLo ad()

// next, your specific code for this page
}

...
}

I hope it helps,

--
Sorin Dolha [MCAD, MCSD .NET]
"Dmitri Shvetsov" <ds*******@cox. net> wrote in message news:evY0c.1242 5$id3.8678@fed1 read01...
Hi,

You know if it should be a very short code it would be fine, but it's only a part of the code and these few strings should be executed before the rest of the On_Load code that's different for each page and already done. So, I can't just derive the page from my own class. Although it could be a good idea and I will think about it. Maybe in this case we can avoid some extra code and just derive some common part of the code just sending the predefined constants to the constructors. Thanks.

Dmitri.
"Sorin Dolha [MCSD .NET]" <sd****@hotmail .com> wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Dmitri,

Why don't you create a new class (let's call it MyPage) derived from Page, overload the OnLoad() method in MyPage, and then change the base type for every of your web pages' classes to MyPage instead of Page.

This technique is a very common technique for adding common functionality to web pages (it's almost like the master template page concept which will be available in ASP .NET "Whidbey").

--
Sorin Dolha [MCAD, MCSD .NET]
"Dmitri Shvetsov" <ds*******@cox. net> wrote in message news:fWU0c.1237 9$id3.3055@fed1 read01...
Not so easy. I need to do the same steps during ON_LOAD for every asp page.
That's why I need to insert the same strings to compile them in different
classes. If I could use an external file and define a static variables etc.,
it would be a big difference.

Dmitri.

"C# Learner" <cs****@learner .here> wrote in message
news:e6******** ******@TK2MSFTN GP09.phx.gbl...
Dmitri Shvetsov wrote:
Hi All,

Does somebody know how can I include an external file into my C# source
file?

I need to insert the same strings (about 5-10) into about 75 different
files, probably I will need to modify all these strings later, and I see it as a good idea to use an INSERT approach, but C# is not C++ and doesn't
allow me just to insert some external file as I used to do. What's a command for that?

Thanks,
Dmitri.


Create a class in its own file, and add the string constants to it.

e.g.:

public sealed class StringConstants
{
// private constructor to stop it getting instantiated
private StringConstants ()
{
}

public const string One = "One";
public const string Two = "Two";
}

Then later you can use StringConstants .One, etc.

Nov 15 '05 #6
O, yeah, it really helps, thanks a lot!

I think that the question is closed. It's very bad that we can't import an external file as an additional code, but using this inheritance can help to solve this problem.

Dmitri.
"Sorin Dolha [MCSD .NET]" <sd****@hotmail .com> wrote in message news:uA******** ******@TK2MSFTN GP09.phx.gbl...
It doesn't matter how much code you need to run. And you can use the method I have described even if you have different code on the web pages OnLoad methods by overriding OnLoad twice, once in the MyBasePage (template) class and once in every web page's class, like this:

class MyBasePage : Page
{
public override OnLoad(...)
{
base.OnLoad(); // call the standard Page.OnLoad()

// next, your lines which should execute on every page
}

...
}

// repeat this for every page you currently have in the web site
// basically you will only need to insert "base.OnLoa d()" line, and change : Page to : MyBasePage for every web page class
class AWebPage : MyBasePage
{
public override OnLoad(...) // override
{
base.OnLoad(); //calls MyBasePage.OnLo ad()

// next, your specific code for this page
}

...
}

I hope it helps,

--
Sorin Dolha [MCAD, MCSD .NET]
"Dmitri Shvetsov" <ds*******@cox. net> wrote in message news:evY0c.1242 5$id3.8678@fed1 read01...
Hi,

You know if it should be a very short code it would be fine, but it's only a part of the code and these few strings should be executed before the rest of the On_Load code that's different for each page and already done. So, I can't just derive the page from my own class. Although it could be a good idea and I will think about it. Maybe in this case we can avoid some extra code and just derive some common part of the code just sending the predefined constants to the constructors. Thanks.

Dmitri.
"Sorin Dolha [MCSD .NET]" <sd****@hotmail .com> wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Dmitri,

Why don't you create a new class (let's call it MyPage) derived from Page, overload the OnLoad() method in MyPage, and then change the base type for every of your web pages' classes to MyPage instead of Page.

This technique is a very common technique for adding common functionality to web pages (it's almost like the master template page concept which will be available in ASP .NET "Whidbey").

--
Sorin Dolha [MCAD, MCSD .NET]
"Dmitri Shvetsov" <ds*******@cox. net> wrote in message news:fWU0c.1237 9$id3.3055@fed1 read01...
Not so easy. I need to do the same steps during ON_LOAD for every asp page.
That's why I need to insert the same strings to compile them in different
classes. If I could use an external file and define a static variables etc.,
it would be a big difference.

Dmitri.

"C# Learner" <cs****@learner .here> wrote in message
news:e6******** ******@TK2MSFTN GP09.phx.gbl...
Dmitri Shvetsov wrote:
Hi All,

Does somebody know how can I include an external file into my C# source
file?

I need to insert the same strings (about 5-10) into about 75 different
files, probably I will need to modify all these strings later, and I see it as a good idea to use an INSERT approach, but C# is not C++ and doesn't
allow me just to insert some external file as I used to do. What's a command for that?

Thanks,
Dmitri.


Create a class in its own file, and add the string constants to it.

e.g.:

public sealed class StringConstants
{
// private constructor to stop it getting instantiated
private StringConstants ()
{
}

public const string One = "One";
public const string Two = "Two";
}

Then later you can use StringConstants .One, etc.

Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
5084
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is relative NOT to the immediate script that is including it, but is relative to the top-level calling script. In practice, this means that you have to constantly worry and adjust paths in includes, based on the startup scripts that call these...
0
6117
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug file as folows. I need help to resolve them ASAP: cl /c /nologo /MDd /W3 /Od /GR /GM /Zi /GX /D "_DEBUG" /D " WIN32" /D "_W INDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /
60
8269
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header associated with this source file For example, in a file hello.c: #include <stdio.h>
9
6406
by: zolli | last post by:
Hi, I've been banging my head against this for a while now. Hoping someone here can shed some light on what's going on. On including stdlib.h in a file, I'm seeing the following errors: ----BEGIN ERRORS---- gcc -g3 -DUSE_LIBC -Wall -c -I../mm -I../include -I/usr/include -I/usr/include/linux -o mm_tree_test.o mm_tree_test.c
5
2506
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to very carefully define the order in which paths are searched with command line options on the compiler. Both can cause problems, especially when dealing with complex software distributions. It occurs ot me that by extending the C include...
1
7475
by: Minh | last post by:
I've just installed VS.NET 2003 on my Athlon XP 1800+. However I couldn't get any project with STL includes to compile even if I create a new empty project (and added #include <string>). It gave me a bunch of "missing ;" errors. I did reinstall the whole thing a few times but it didn't work. Anyone have any idea? Thanks c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xutility(862) :
1
4563
by: ya man | last post by:
when i use #include <iostream.h> in some files i get lots of error messages of the kind 'ambiguous symbol this is solved when i use #include <iostream why is that ? and can i use #include <iostream.h> in some way examples to the error messages c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\streamb.h(90): error C2872: 'ios' : ambiguous symbo c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\streamb.h(90): error C2872:...
3
2699
by: Arpi Jakab | last post by:
I have a main project that depends on projects A and B. The main project's additional include directories list is: ...\ProjectA\Dist\Include ...\ProjectB\Dist\Include Each of the include directories contain a file named "cppfile1.h". In my main project I #include "cppfile1.h". I rely on the order of paths in additional include directories list to get file cppfile1.h from ProjectA and
14
6690
by: Jon Rea | last post by:
I am currently cleaning up an application which was origainlly hashed together with speed of coding in mind and therefore contains quite a few "hacky" shortcuts. As part of this "revamping" process I am introducing namespaces to properly compartmentalise sections of the code into logical units. What I am speciffically trying to get right is the dependency tree for header files to reduce compile time and simplify the code structure. On...
7
2913
by: Giancarlo Bassi | last post by:
Please, what are here the 11 include files (found over the internet)? */mozzarella.c /* #include #include #include #include #include #include
0
8420
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.