Click here to Skip to main content
15,879,474 members
Home / Discussions / C#
   

C#

 
AnswerRe: is a File Read Only. Pin
N a v a n e e t h5-Aug-07 22:53
N a v a n e e t h5-Aug-07 22:53 
AnswerRe: is a File Read Only. Pin
Nouman Bhatti6-Aug-07 2:05
Nouman Bhatti6-Aug-07 2:05 
Questioninternal and internal protected Pin
Sonia Gupta5-Aug-07 22:25
Sonia Gupta5-Aug-07 22:25 
AnswerRe: internal and internal protected Pin
N a v a n e e t h5-Aug-07 22:46
N a v a n e e t h5-Aug-07 22:46 
GeneralRe: internal and internal protected Pin
Sonia Gupta5-Aug-07 23:00
Sonia Gupta5-Aug-07 23:00 
GeneralRe: internal and internal protected Pin
N a v a n e e t h6-Aug-07 1:13
N a v a n e e t h6-Aug-07 1:13 
AnswerRe: internal and internal protected Pin
m@u5-Aug-07 23:41
m@u5-Aug-07 23:41 
AnswerRe: internal and internal protected Pin
Hessam Jalali5-Aug-07 23:46
Hessam Jalali5-Aug-07 23:46 
Create these classes inside a ClassLibrary
<br />
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace InternalAssembly<br />
{<br />
    public class BasicTaskClass<br />
    {<br />
        string str=null;<br />
<br />
<br />
        protected virtual void DoTask()<br />
        {<br />
            return;<br />
        }<br />
<br />
        internal void DoJob()<br />
        {<br />
         //codes for control and ...<br />
         this.DoTask();<br />
        }<br />
<br />
        protected internal string Data<br />
        {<br />
            get<br />
            {<br />
                //codes for other task and controls<br />
                return this.str;<br />
            }<br />
            set<br />
            {<br />
                //code for other tasks and controls<br />
                this.str = value;<br />
            }<br />
        }<br />
 <br />
     }<br />
<br />
<br />
   public sealed class DoTaskClass<br />
    {<br />
       public string Go(string str, BasicTaskClass tsk)<br />
       {<br />
           tsk.Data = str;<br />
           tsk.DoJob();<br />
           return tsk.Data;<br />
       }<br />
<br />
    }<br />
<br />
}<br />


and create these in the ConsoleApplication and then add ClassLibrary you made before as a reference

</code>
using System;
using System.Collections.Generic;
using System.Text;

namespace InternalProtectedDemo
{
    class UpperCaseTask:InternalAssembly.BasicTaskClass
    {
        protected override void DoTask()
        {
            this.Data=this.Data.ToUpper();
        }
    }



    class Program
    {
        static void Main(string[] args)
        {
            InternalAssembly.DoTaskClass doTaskClass = new InternalAssembly.DoTaskClass();

            InternalAssembly.BasicTaskClass basicTask = new InternalAssembly.BasicTaskClass();

            basicTask.DoJob(); //produce error [comment it]

            Console.WriteLine(doTaskClass.Go("hello", new InternalAssembly.BasicTaskClass())); //output= hello
            Console.WriteLine(doTaskClass.Go("hello", new UpperCaseTask())); //output= HELLO

            Console.ReadKey();
        }
    }
}
</code>


as you can see you cannot access to Data properties or DoTask method
without deriving from the BasicTaskClass in other assemblies.
and you can't access to DoJob method even with derivation.

these going to be very useful in large applications or expandable ones and this example is not showing this!!!

sorry nothing better than this crossed my mind
AnswerRe: internal and internal protected Pin
Pete O'Hanlon6-Aug-07 1:34
mvePete O'Hanlon6-Aug-07 1:34 
GeneralRe: internal and internal protected Pin
Sonia Gupta6-Aug-07 1:41
Sonia Gupta6-Aug-07 1:41 
GeneralRe: internal and internal protected Pin
Pete O'Hanlon6-Aug-07 2:42
mvePete O'Hanlon6-Aug-07 2:42 
GeneralRe: internal and internal protected Pin
originSH6-Aug-07 4:03
originSH6-Aug-07 4:03 
QuestionTake over a GUI of running program Pin
Morad Kobi5-Aug-07 22:21
Morad Kobi5-Aug-07 22:21 
AnswerRe: Take over a GUI of running program Pin
Hessam Jalali6-Aug-07 23:17
Hessam Jalali6-Aug-07 23:17 
Questionregarding xml's property dynamically Pin
praveenkumar palla5-Aug-07 21:51
praveenkumar palla5-Aug-07 21:51 
QuestionDataAdapter.Fill() Pin
blackjack21505-Aug-07 21:43
blackjack21505-Aug-07 21:43 
AnswerRe: DataAdapter.Fill() Pin
Marek Grzenkowicz5-Aug-07 22:04
Marek Grzenkowicz5-Aug-07 22:04 
AnswerRe: DataAdapter.Fill() Pin
N a v a n e e t h5-Aug-07 22:49
N a v a n e e t h5-Aug-07 22:49 
AnswerRe: DataAdapter.Fill() Pin
Nouman Bhatti6-Aug-07 2:12
Nouman Bhatti6-Aug-07 2:12 
QuestionFind Out the executed page??? Pin
mimimimilaw5-Aug-07 21:08
mimimimilaw5-Aug-07 21:08 
QuestionCalling unmanaged DLL-methodes (winmm.dll) Pin
J. Holzer5-Aug-07 20:32
J. Holzer5-Aug-07 20:32 
AnswerRe: Calling unmanaged DLL-methodes (winmm.dll) Pin
m@u5-Aug-07 21:29
m@u5-Aug-07 21:29 
AnswerRe: Calling unmanaged DLL-methodes (winmm.dll) Pin
originSH5-Aug-07 21:57
originSH5-Aug-07 21:57 
QuestionODBC how to connect reomte SQL Server Pin
jason_mf5-Aug-07 20:16
jason_mf5-Aug-07 20:16 
AnswerRe: ODBC how to connect reomte SQL Server Pin
Guffa5-Aug-07 20:29
Guffa5-Aug-07 20:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.