How would you implement a form having two components where one component updates another?

For such cases, we can simply create a Shared service which holds the value, which one component updates and other component binds in its view.

@Injectable()
export class MyService {
    myVal: string;
}

@Component()
export class Component1 {
    constructor(private myService: MyService) {}
    onUpdated(newVal) {
       this.myService.myVal = newVal;
    }
}

@Component() {
export class Component2 implements OnInit {
  myVal: string;
  constructor(private myService: MyService) {}
  ngOnInit() {
    this.myVal = this.myService.myVal;
  }
}

How can you performance tune a Stored Procedure?

  • Use column names instead of * in SELECT query
  • Reduce the use of temp tables created in the SP, delete the tables once their use is over.
  • Create indexes on frequently queried columns,
  • use JOIN statements instead of sub-queries or correlated sub-queries.

Explain async and await

  • async and await keywords are used for asynchronous operations
  • awaiting a process puts in a separate task and returns the reference to that task.
  • Once complete the runtime makes sure that the process starts execution back from where the await process occurs
  • A method in which an await keyword is used should be marked async
public async Task<string> DoSomething() {
    var res = await httpClient.GetAsync("SOME_GET_API");
    return await res.Content.ReadAsStringAsync();
}

What is the difference between Finalize() and Dispose() methods?

  • Object.Finalize() method releases unmanaged resources but don't assure garbage collection. It is called before the Garbage Collector reclaims the memory. It is also called as a destructor, which is complementary to the constructor, where memory allocation happens.
public class MyClass {
  ~MyClass() {
    // any custom release operations
  }
}

How can I call the base implementation of an overridden virtual method?

Using the C# language constructs, you cannot explicitly call the base function from outside the scope of A or B. If you really need to do that, then there is a flaw in your design - i.e. that function shouldn't be virtual to begin with, or part of the base function should be extracted to a separate non-virtual function.

class A
{
  virtual void X() { Console.WriteLine("x"); }
}

class B : A
{
  override void X() { Console.WriteLine("y"); }
}

class Program
{
  static void Main()
  {
    A b = new B();
    // Call A.X somehow, not B.X...
  }
}

What is LINQ?

  • LINQ stands for Language Integrated Queries
  • LINQ library offers a set of features to perform data operations irrespective of data sources
  • It can be used to bridge between objects and data
Privacy Overview
Referbruv

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

3rd Party Cookies

This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.

Keeping this cookie enabled helps us to improve our website.