Cost of painting n * m grid | C # implementation of the approach ; Function to return the minimum cost ; Driver code
using System ; class GFG { static int getMinCost ( int n , int m ) { int cost = ( n - 1 ) * m + ( m - 1 ) * n ; return cost ; } public static void Main ( ) { int n = 4 , m = 5 ; Console . WriteLine ( getMinCost ( n , m ) ) ; } }